flowise / packages /server /src /DataSource.ts
rohan13's picture
Flowise Changes
4114d85
raw
history blame contribute delete
719 Bytes
import 'reflect-metadata'
import path from 'path'
import { DataSource } from 'typeorm'
import { ChatFlow } from './entity/ChatFlow'
import { ChatMessage } from './entity/ChatMessage'
import { getUserHome } from './utils'
let appDataSource: DataSource
export const init = async (): Promise<void> => {
const homePath = path.join(getUserHome(), '.flowise')
appDataSource = new DataSource({
type: 'sqlite',
database: path.resolve(homePath, 'database.sqlite'),
synchronize: true,
entities: [ChatFlow, ChatMessage],
migrations: []
})
}
export function getDataSource(): DataSource {
if (appDataSource === undefined) {
init()
}
return appDataSource
}