-
Type:
Task
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When inserting documents, the documents are being modified. This means that the client has to be aware of the modifications and has to make copies of the documents if it needs the documents unmodified after inserting.
Please confirm that this is the intended behavior.
The following code gives an example; the printout shows the modifications. When printing the original document after the insert, fields are added.
var Db = require('mongodb').Db,
Server = require('mongodb').Server,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Code = require('mongodb').Code,
BSON = require('mongodb').pure().BSON,
assert = require('assert');
var db = new Db('jiras', new Server("127.0.0.1", 27017,
),
{w: 0, native_parser: false});
db.open(function (err, db) {
db.dropCollection("inputModification", function (err, result) {
db.createCollection('inputModification', function (err, collection) {
var randomStringDocument =
;
console.log("original document:");
console.log(randomStringDocument);
collection.insert(randomStringDocument,
{w: 1}, function (err, result) {
var randomStringQuery =
;
var cursor;
var cursorStream;
cursor = collection.find(randomStringQuery);
cursorStream = cursor.stream();
cursorStream.on("data", function (docs)
);
cursorStream.on("close", function ()
);
});
});
});
});