mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Excluding fields not working on Model.find

Open ice-bin-ux opened this issue 10 years ago • 3 comments

Topic_Model.find(cmd,'-is_draft',{sort:'-create_at'},callback) i pass the param '-is_draft' but when run the application ,the query is wating,it does't return any thing. and final the application catch the error FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory. but when i pass another field this model '-tags' it worked,why?

ice-bin-ux avatar Oct 14 '16 03:10 ice-bin-ux

@onlyoneice can you provide the full code?

enrichz avatar Oct 14 '16 12:10 enrichz

@enrichz

var TopicSchema = new Schema({     
  title:{type:String},     
  content:{type:String},  
  cover_image:{type:String,default:null},  
  author_id:{type:String},  
  author_nick_id:{type:String},  
  close:{type:Boolean,default:false},  
  reply_count:{type:Number,default:0},  
  visit_count:{type:Number,default:0},  
  collect_count:{type:Number,default:0},  
  tab:{type:String},  
  ups:[String],  
  tags:[String],  
  last_reply:{type:String,default:''},  
  last_reply_at:{type:Date,default:Date.now},  
  is_draft:{type:Boolean,default:false},  
  delete:{type:Boolean,default:false},  
  create_at:{type:Date,default:Date.now},  
  update_at:{type:Date,default:Date.now}
});

and the query is Topic_Model.find({delete:false,tab:tab},null,{sort:'-create_at',skip:skipsize,limit:pagesize},callback);

but when i Topic_Model.find({delete:false,tab:tab},'-tags',{sort:'-create_at',skip:skipsize,limit:pagesize},callback); is ok,so i don't understand why?

ice-bin-ux avatar Oct 14 '16 23:10 ice-bin-ux

@enrichz i found the reason ,it cause by another package,not mongoose,thanks

ice-bin-ux avatar Oct 15 '16 01:10 ice-bin-ux