mirror of
https://github.com/iptv-org/iptv.git
synced 2024-07-05 12:02:35 +02:00
23 lines
469 B
TypeScript
23 lines
469 B
TypeScript
|
import Datastore from '@seald-io/nedb'
|
||
|
import * as path from 'path'
|
||
|
|
||
|
export class Database {
|
||
|
rootDir: string
|
||
|
|
||
|
constructor(rootDir: string) {
|
||
|
this.rootDir = rootDir
|
||
|
}
|
||
|
|
||
|
async load(filepath: string) {
|
||
|
const absFilepath = path.join(this.rootDir, filepath)
|
||
|
|
||
|
return new Datastore({
|
||
|
filename: path.resolve(absFilepath),
|
||
|
autoload: true,
|
||
|
onload: (error: Error): any => {
|
||
|
if (error) console.error(error.message)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|