简体   繁体   English

如何用快递在猫鼬内无条件申请?

[英]How to Apply not in condition inside the populate in mongoose with express?

How to apply "not in" query inside populate as below in Mongoose with Express js ? 如何使用Express js在Mongoose中按以下方式在内部填充“ not in”查询?

Users
  .find({ user_enabled: true })
  .populate({
    path: 'books',
    match: { 'language': 'en' }, 

[ Not in en language ] [不是用英语]

  })
  .exec()

You may use $nin Comparison Query Operator for this 您可以为此使用$ nin比较查询运算符

Example: 例:

Users
  .find({ user_enabled: true })
  .populate({
    path: 'books',
    match: { 'language': 'en' }, 
    match: { "language": { "$nin": ['xx','yy'] } }  // <= See here
  })
  .exec()
Users
  .find({ user_enabled: true })
  .populate({
    path: 'books',
    match: { 'language': {$not: 'en'} }, })
  .exec()

Have you tried $ne operator? 您是否尝试过$ne运算符?

So in your case: 因此,在您的情况下:

Users
  .find({ user_enabled: true })
  .populate({
    path: 'books',
    match: { language: { $ne: "en" } },
})
.exec() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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