Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

MongoDB 查询操作符


MongoDB 查询操作符

有很多查询操作符可以用来比较和引用文档字段。

比较

以下操作符可以在查询中用于比较值

  • $eq: 值相等
  • $ne: 值不相等
  • $gt: 值大于另一个值
  • $gte: 值大于或等于另一个值
  • $lt: 值小于另一个值
  • $lte: 值小于或等于另一个值
  • $in: 值匹配数组中的某个值

逻辑

以下操作符可以逻辑比较多个查询。

  • $and: 返回两个查询都匹配的文档
  • $or: 返回任一查询匹配的文档
  • $nor: 返回两个查询都不匹配的文档
  • $not: 返回查询不匹配的文档

评估

以下操作符有助于评估文档。

  • $regex: 允许在评估字段值时使用正则表达式
  • $text: 执行文本搜索
  • $where: 使用 JavaScript 表达式匹配文档

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.