Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoose select:false an array of ObjectIds

Tags:

mongoose

I'm trying to do something very similar to this, except that I do not want to reference the child object's schema directly. I'm using the ObjectId & Ref notation:

children: [{ type: mongoose.Schema.Types.ObjectId, ref: 'SomeSchema' }]

Is there anyway to achieve this? I don't see anything in the docs.

like image 500
phillipwei Avatar asked Dec 02 '22 17:12

phillipwei


1 Answers

In retrospect, this should have been obvious:

children: { 
    type: [{ type: mongoose.Schema.Types.ObjectId, ref: 'SomeSchema'}],  
    select: false 
} 
like image 93
phillipwei Avatar answered Jun 23 '23 08:06

phillipwei