Comparing version 0.5.2 to 0.5.3
@@ -142,3 +142,3 @@ var fs = require('fs') | ||
self.datafileSize += 1; | ||
return callback(null, insertedDoc); | ||
return callback(null, model.deepCopy(insertedDoc)); | ||
}); | ||
@@ -145,0 +145,0 @@ }; |
{ | ||
"name": "nedb", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "tldr.io", |
@@ -293,4 +293,3 @@ # NeDB (Node embedded database) | ||
Connect and Express, backed by nedb | ||
* I'm planning on making an export tool to get all your data in a nedb | ||
database in a Mongo database | ||
* If you've outgrown NeDB, switching to MongoDB won't be too hard as it is the same API. Use <a href="https://github.com/louischatriot/nedb-to-mongodb" target="_blank">this utility</a> to transfer the data from a NeDB database to a MongoDB collection | ||
@@ -297,0 +296,0 @@ |
@@ -321,2 +321,13 @@ var Datastore = require('../lib/datastore') | ||
it('Modifying the insertedDoc after an insert doesnt change the copy saved in the database', function (done) { | ||
d.insert({ a: 2, hello: 'world' }, function (err, newDoc) { | ||
newDoc.hello = 'changed'; | ||
d.findOne({ a: 2 }, function (err, doc) { | ||
doc.hello.should.equal('world'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); // ==== End of 'Insert' ==== // | ||
@@ -501,2 +512,24 @@ | ||
it('Changing the documents returned by find or findOne do not change the database state', function (done) { | ||
d.insert({ a: 2, hello: 'world' }, function () { | ||
d.findOne({ a: 2 }, function (err, doc) { | ||
doc.hello = 'changed'; | ||
d.findOne({ a: 2 }, function (err, doc) { | ||
doc.hello.should.equal('world'); | ||
d.find({ a: 2 }, function (err, docs) { | ||
docs[0].hello = 'changed'; | ||
d.findOne({ a: 2 }, function (err, doc) { | ||
doc.hello.should.equal('world'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); // ==== End of 'Find' ==== // | ||
@@ -503,0 +536,0 @@ |
114315
2452
320