【Pymongo】Cursor类 可调用函数详解

【Pymongo】Cursor类函数详解

clone()

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Get a clone of this cursor.
获取此光标的克隆。

collation(collation: Optional[Union[Mapping[str, Any], Collation]])

→ Cursor[_DocumentType]

Adds a Collation to this query.
向此查询添加集合 。
(翻译给的是排序规则,应该理解为集合)

Parameters

collation: An instance of Collation.
集合的实例

distinct(key: str)

→ List

Get a list of distinct values for key among all documents in the result set of this query.
获取此查询结果集中所有文档中key的不同值列表。

Parameters

key: name of key for which we want to get the distinct values
键的名称,我们希望得到不同的值

explain()

→ pymongo.typings._DocumentType

Returns an explain plan record for this cursor.
返回此游标的解释计划记录。

limit(limit: int)

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Parameters

limit: the number of results to return
返回结果的数量

max(spec: Sequence[Tuple[str, Union[int, str, Mapping[str, Any]]]])

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Adds max operator that specifies upper bound for specific index.

When using max, hint() should also be configured to ensure the query uses the expected index and starting in MongoDB 4.2 hint() will be required.

添加指定特定索引上限的max运算符。

在使用max时,还应该配置hint()以确保查询使用预期的索引,并在MongoDB中启动4.2 hint()。

min(spec: Sequence[Tuple[str, Union[int, str, Mapping[str, Any]]]])

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Adds min operator that specifies lower bound for specific index.

When using min, hint() should also be configured to ensure the query uses the expected index and starting in MongoDB 4.2 hint() will be required.
添加指定特定索引下界的最小操作符。

在使用min时,还应该配置hint()以确保查询使用预期的索引,并在MongoDB 4.2中启动hint()。

skip(skip: int)

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Skips the first skip results of this cursor.
跳过此游标的第一个跳过结果。

sort(key_or_list: Union[str, Sequence[Tuple[str, Union[int, str, Mapping[str, Any]]]]], direction: Optional[Union[int, str]] = None)

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Sorts this cursor’s results.
对游标的结果进行排序。

Parameters

key_or_list: a single key or a list of (key, direction) pairs specifying the keys to sort on

direction (optional): only used if key_or_list is a single key, if not given ASCENDING is assumed
Key_or_list:单个键或(键,方向)对列表,指定要排序的键

direction(可选):仅当key_or_list是单个键时使用,如果没有给定ASCENDING则使用

where(code: Union[str, bson.code.Code])

→ pymongo.cursor.Cursor[pymongo.typings._DocumentType]

Adds a $where clause to this query.

The code argument must be an instance of basestring (str in python 3) or Code containing a JavaScript expression. This expression will be evaluated for each document scanned. Only those documents for which the expression evaluates to true will be returned as results. The keyword this refers to the object currently being scanned.

向该查询添加$where子句。

code参数必须是一个basestring (python 3中的str)或包含JavaScript表达式的code的实例。 将对扫描到的每个文档计算该表达式。 只有表达式求值为true的文档才会返回结果。 关键字this指的是当前正在扫描的对象。
Parameters
code: JavaScript expression to use as a filter
用作过滤器的JavaScript表达式

posted @ 2022-06-28 00:14  libai1024  阅读(603)  评论(0编辑  收藏  举报