title: MongoError: Can't canonicalize query: BadValue >1
body: <p>Good evening,</p>
  
  <p>I've been busy with Mongoosejs + Node.js, and I've got the following error at the moment.</p>
  
  <pre><code>[Login-01][ERROR] MongoError: Can't canonicalize query: BadValue &gt;1 field in obj: { 
  _events: {}, _posts: { save: [] }, _pres: { save: [] }, _doc: { _id: 
  ObjectId('537a652e88d1ff281aa9ce95'), name: "Diamondo25", banResetDate: null, 
  creationDate: new Date(1400530222052), female: null, isAdmin: false, __v: 0, password: 
  "---", salt: "---" }, _maxListeners: 0, errors: null, isNew: false, $__: { fullPath:
   null, ownerDocument: null, activePaths: { stateNames: [ "require", "modify", "init",
   "default" ], states: { require: {}, modify: {}, init: { _id: true, name: true, 
  banResetDate: true, creationDate: true, female: true, isAdmin: true, __v: true, 
  password: true, salt: true }, default: {} }, paths: { _id: "init", name: "init", 
  banResetDate: "init", creationDate: "init", female: "init", isAdmin:"init", __v: 
  "init", password: "init", salt: "init" } }, scope: null, wasPopulated: false, 
  populated: null, populate: null, _id: null, getters: {}, version: null, inserting: 
  null, removing: null, adhocPaths: null, validationError: null, saveError: null, 
  shardval: null, selected: null, strictMode: true } }
  </code></pre>
  
  <p>I cannot reproduce the error in a simple variant of the triggering code (which is ran inside a callback of a TCP packet).</p>
  
  <pre><code>function test() {
      var document = FindDocumentByCutoffId(Character, 1400622496);
      console.log(document);
      console.log(document.remove());
  }
  wait.launchFiber(test);
  </code></pre>
  
  <p><code>character</code> inside the callback of <code>SetHandler</code> is the same object as the one that is logged by the code above.</p>
  
  <pre><code>PacketHandler.SetHandler(0x0017, function (pSocket, pReader) {
      var id = pReader.ReadUInt32();
      var character = FindDocumentByCutoffId(Character, id, {
          account: pSocket.account,
          worldId: pSocket.state.worldId
      });
  
      if (!character) {
          pSocket.Disconnect();
          return;
      }
      wait.forMethod(character, 'remove');
  });
  
  global.FindDocumentByCutoffId = function (pSchema, pDocumentId, pFilterAdditions) {
      var filter = pFilterAdditions || {};
      pDocumentId = pDocumentId.toString(16);
  
      // Get all rows
      var rows = wait.forMethod(pSchema, 'find', '_id', filter);
  
      for (var i = 0; i &lt; rows.length; i++) {
          if (String(rows[i]._id).indexOf(pDocumentId) == 0) {
              return wait.forMethod(pSchema, 'findById', rows[i]._id);
          }
      }
  
      return null;
  };
  </code></pre>
  
  <p><strong>Edit:</strong> Wait a second. Why does it print the Account object inside the error? O_o</p>