Get the App
SLTechnology News&Howtos  ›  Database  › 

Drill down to query expression

Shulou Source: shulou.com Published: 2022-06-01 22:38:08 11月07日 Update

($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

Tags: Queries expressions documents conditions actions objects structures grammars speeds Nokia binary goods fields attributes beginnings data arrays regularities recommendations Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Linux macOS Xiaomi