mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update db.js
This commit is contained in:
parent
e6ff94625c
commit
a07c330a43
1 changed files with 8 additions and 1 deletions
|
@ -6,8 +6,11 @@ const DB_DIR = process.env.DB_DIR || './scripts/database'
|
||||||
class Database {
|
class Database {
|
||||||
constructor(filepath) {
|
constructor(filepath) {
|
||||||
this.filepath = filepath
|
this.filepath = filepath
|
||||||
|
}
|
||||||
|
|
||||||
|
load() {
|
||||||
this.db = nedb.create({
|
this.db = nedb.create({
|
||||||
filename: file.resolve(filepath),
|
filename: file.resolve(this.filepath),
|
||||||
autoload: true,
|
autoload: true,
|
||||||
onload: err => {
|
onload: err => {
|
||||||
if (err) console.error(err)
|
if (err) console.error(err)
|
||||||
|
@ -36,6 +39,10 @@ class Database {
|
||||||
return this.db.persistence.compactDatafile()
|
return this.db.persistence.compactDatafile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopAutocompact() {
|
||||||
|
return this.db.persistence.stopAutocompaction()
|
||||||
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
return file.clear(this.filepath)
|
return file.clear(this.filepath)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue