简体   繁体   中英

[Mongodb]Get document if value list is intersection

I have user docs that have a list of intruments that each user plays

User = new mongoose.schema(){
    // skiped stuff
    instruments: [String]
    // more skipped stuff
}

my path function takes in a list of instruments and I want all the docs where a user plays any instrument in the input instrument list

I have been trying to use

{instruments:{
    $elemMatch: {
        $in: inputInstrumentList // thought something like this would work :/
    }
}

but that is only giving me errors

pre-emptive thanks for any and all help

正如chridam所展示的那样,我对此事考虑得太深了,$ in可以完美地工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM