nosql.each throws an error when the database is empty
mattijs79 opened this issue · 1 comments
nosql.each gives the error SyntaxError: Unexpected end of input at: each-buffer when being called on an empty database, but not when the database doesn't exist.
Code to reproduce:
var fs = require('fs');
fs.unlink('./bug.nosql');
var nosql = require('nosql').load('./bug.nosql');
nosql.on('error', function(err, source) {
console.log('Error: ' + err + ' at: ' + source);
});
nosql.on('load', function() {
nosql.each(function(doc){
// do nothing
},function(){
console.log('First nosql.each callback');
});
nosql.insert({ firstName: 'Peter', lastName: 'Širka', age: 28 }, function() {
nosql.remove(function(doc) {
return (doc !== null && doc.firstName === 'Peter');
}
,function(count) {
console.log('Removed: ' + count);
nosql.each(function(doc){
// do nothing
},function(){
console.log('Second nosql.each callback');
});
});
});
});
Hi @mattijs79,
thanks for reporting the problem. I fixed it.
Please download a new version from NPM 👍
Thanks.