Comparing version 0.0.4 to 0.0.5
@@ -132,3 +132,3 @@ /** | ||
if (Datastore.match(self.data[i], query)) { | ||
res.push(self.data[i]); | ||
res.push(model.deepCopy(self.data[i])); | ||
} | ||
@@ -152,3 +152,3 @@ } | ||
if (Datastore.match(self.data[i], query)) { | ||
return callback(null, self.data[i]); | ||
return callback(null, model.deepCopy(self.data[i])); | ||
} | ||
@@ -155,0 +155,0 @@ } |
{ | ||
"name": "nedb", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "tldr.io", |
@@ -111,2 +111,26 @@ var Datastore = require('../lib/datastore') | ||
it('If an object returned from the DB is modified and refetched, the original value should be found', function (done) { | ||
d.insert({ a: 'something' }, function () { | ||
d.findOne({}, function (err, doc) { | ||
doc.a.should.equal('something'); | ||
doc.a = 'another thing'; | ||
doc.a.should.equal('another thing'); | ||
// Re-fetching with findOne should yield the persisted value | ||
d.findOne({}, function (err, doc) { | ||
doc.a.should.equal('something'); | ||
doc.a = 'another thing'; | ||
doc.a.should.equal('another thing'); | ||
// Re-fetching with find should yield the persisted value | ||
d.find({}, function (err, docs) { | ||
docs[0].a.should.equal('something'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); // ==== End of 'Insert' ==== // | ||
@@ -113,0 +137,0 @@ |
43661
1145