Here is my schema definition:
var DocSchema = new mongoose.Schema({
  _id: {
    name: String,
    path: String
  },
  label: String,
  ...
});
mongoose.model('Doc', DocSchema, 'doc_parse_utf8');
var Doc = mongoose.model('Doc');
And the documents have been inserted to mongodb by other program. Then I tried to query the document:
Doc.findOne({_id:{name:name,path:path}}, function(err, doc){
  if (err && err_handler) {
    err_handler(err);
  } else if(callback) {
    callback(doc);
  }
});
But, a cast error will be reported:
{ message: 'Cast to ObjectId failed for value "[object Object]" at path "_id"',
  name: 'CastError',
  type: 'ObjectId',
  value: { name: 'mobile', path: 'etc/' },
  path: '_id' }
I have searched this problem on mongoose's document, google and statckoverflow.com, however, there's no any solution for me. Please help, thanks.
 
     
    