$in 操作符

  The $in operator selects the documents where the value of a field equals any value in the specified array. 

  $in 选择包含指定值之一的 doc。

  $in 操作符

  If the field holds an array, then the $in operator selects the documents whose field holds an array that contains at least one element that matches a value in the specified array

Use the $in Operator with a Regular Expression

The $in operator can specify matching values using regular expressions of the form /pattern/. Youcannot use $regex operator expressions inside an $in.

Consider the following example:

db.inventory.find( { tags: { $in: [ /^be/, /^st/ ] } } )

This query selects all documents in the inventory collection where the tags field holds an array that contains at least one element that starts with either be or st.

参考:https://docs.mongodb.org/manual/reference/operator/query/in/#op._S_in

相关文章:

  • 2022-12-23
  • 2021-06-26
  • 2021-11-20
  • 2021-12-05
  • 2021-07-18
  • 2021-08-11
  • 2021-08-23
猜你喜欢
  • 2021-06-18
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案