Skip to content Skip to sidebar Skip to footer

How To Convert Mongo ObjectId .toString Without Including 'ObjectId()' Wrapper -- Just The Value?

What I'm trying to solve is: preserving the order of my array of Ids with $in using this suggested method (mapReduce): Does MongoDB's $in clause guarantee order I've done my homew

Solution 1:

figured it out:

  obj.map = function() {
    for(var i = 0; i < inputs.length; i++){
      if(this._id.equals(inputs[i])) {
        var order = i;
      }
    }
    emit(order, {doc: this});
  };

Post a Comment for "How To Convert Mongo ObjectId .toString Without Including 'ObjectId()' Wrapper -- Just The Value?"