Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Drill down to query expression

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

($where,$regex is not recommended! Slow)

Query expression:

1: the simplest query expression

{filed:value}, which refers to querying documents whose field column has a value of value

2: $ne--! = query expression

{field: {$nq:value}}

Function-check documents where the value of filed column is not equal to value

3: $nin-- > not in

4: $all

Syntax: {field: {$all: [v1Magne v2..]}}

Indicates that the field column is an array and contains at least v1 and v2 values

5: $exists

Syntax: {field: {$exists:1}}

Function: query out documents with field fields

6: $nor

{$nor, [condition 1, condition 2]}

It means that a document that does not meet all conditions is returned as true.

7: use regular expressions to query products that start with "Nokia"

Example: db.goods.find ({goods_name:/ Nokia. * /}, {goods_name:1})

8: query with $where expression

Example: db.goods.find ({$where:'this.cat_id! = 3 & & this.cat_id! = 11'})

9: $regex

Note: when querying with $where, mongodb is an object that converts the binary data of the bson structure into the json structure, and then compares whether the object's properties satisfy the expression. Slow speed

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report