whistle.statistics
Version:
statistics for whistle.nohost
35 lines (31 loc) • 787 B
JavaScript
const loki = require('lokijs');
const path = require('path');
const USER_HOME = process.env.HOME || process.env.USERPROFILE;
const dbPath = path.resolve(USER_HOME, "./whistle-statistics.db");
const loadCollection = (collectionName, db) => {
return new Promise(resolve => {
db.loadDatabase({}, () => {
const collection = db.getCollection(collectionName) || db.addCollection(collectionName);
resolve(collection);
})
})
};
const db = new loki(dbPath,
{
//autoload: true,
//autosave: true,
//autosaveInterval: 5
}
);
const dbRead = new loki(dbPath,
{
//autoload: true,
//autosave: true,
//autosaveInterval: 5
}
);
module.exports = {
loadCollection,
db,
dbRead,
};