Input documents are being modified by driver; intentional?

XMLWordPrintableJSON

    • 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,

      {auto_reconnect: false, poolSize: 4}

      ),

      {w: 0, native_parser: false}

      );

      db.open(function (err, db) {
      db.dropCollection("inputModification", function (err, result) {

      db.createCollection('inputModification', function (err, collection) {
      var randomStringDocument =

      {"x": "randomString", "comment": "randomString"}

      ;
      console.log("original document:");
      console.log(randomStringDocument);

      collection.insert(randomStringDocument,

      {w: 1}

      , function (err, result) {
      var randomStringQuery =

      {"x": "randomString"}

      ;
      var cursor;
      var cursorStream;

      cursor = collection.find(randomStringQuery);
      cursorStream = cursor.stream();
      cursorStream.on("data", function (docs)

      { console.log("query:"); console.log(randomStringQuery); console.log("original document:"); console.log(randomStringDocument); console.log("result document:"); console.log(docs); }

      );
      cursorStream.on("close", function ()

      { db.close(); }

      );
      });
      });
      });
      });

              Assignee:
              Christian Amor Kvalheim
              Reporter:
              Christoph Bussler
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: