using dirty in a module
angelochen960 opened this issue · 1 comments
angelochen960 commented
Hi,
I am trying to dirty in a module, sample code below, that code returns 'not loaded', what is a good way to put dirty in a module? Thanks
var dirty = require('dirty');
var db = dirty('sample.db');
var loaded = false
db.on('load', function() {
console.log('loaded')
loaded = true
})
exports.get_all_items = function() {
return new Promise(function (resolve, reject) {
if (loaded)
resovle(loaded) // just a test for now, should return all items in the db
else
reject('not loaded')
})
}
angelochen960 commented
found a solution:
https://gist.github.com/angelochen960/d1eeaf761e2504876919e7ade9697235