Open mauron85 opened 11 years ago
I had this problem as well. Did you edit your .db file manually? I noticed that this problem occurs if you have empty lines in the file; e.g. an empty line at the beginning, or you delete some entries manually and leave your cursor at the beginning of the last -now empty- line instead of at the end of the last populated line upon saving.
No I didn't edit db file manually. I can replicate the issue with my this db: https://dl.dropboxusercontent.com/u/150742/nStore-bug.zip
and followin testing code
var nStore = require('nstore');
nStore = nStore.extend(require('nstore/query')());
var provider = nStore.new('provider.db', function () {
console.log('DB provider loaded');
provider.all(function (err, results) {
if (err) console.log(err);
else {
console.log(results);
results.forEach(function(result) {
console.log(result);
});
}
});
});
I took a quick look at your file and there is definitely something wrong with it; if you have an editor that shows line numbers, you'll see there is a line (25) starting with "photo" instead of a dbase key (after "were_here_count":3383 ). Normally, new lines start with a key. If you delete that line completely (no idea what the missing part is; line 24 is complete, so it looks like there is quite a lot missing from 25), it works.
And in your test code, results is a single object (its keys are the dbase keys) so forEach won't work.
for(var key in results){
console.log(results[key]);
}
So now your problem is reduced to finding out how your db file got corrupt :-)
You're right. Right now i'm investigating what caused the wrong data was written.
Hi, I'm storing results of Google Maps Places search and also Facebook Places into nStore. But after some time I get following error:
version of nStore: 0.5.2