Answer the question
In order to leave comments, you need to log in
How to form a query in Mongoose?
The scheme is
var crm_pixel_Schema = new Schema({
_id: mongoose.Schema.Types.ObjectId,
parent_id: {type: Schema.Types.ObjectId, ref: 'category'},
name: String,
desc: String,
order: Number
})
pModel.findOne()
.sort({order: -1})
.select({_id: 1, order: 1, parent_id: 1})
.where('`_id` = `parent_id`') <=== как вот тут?
.exec()
Answer the question
In order to leave comments, you need to log in
pModel.find()
.sort({order: -1})
.select({_id: 1, order: 1, parent_id: 1})
.$where(function () {
return this._id.toString() === this.parent_id.toString();
})
.exec()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question