当前位置:网站首页>Mongodb sort function
Mongodb sort function
2022-06-29 06:10:00 【icestone_ kai】
Sorting function
cursor.sort({
field: ordering, ...}): Sort according to the specified rules
ordering by 1 Indicates ascending sort
ordering by -1 Represents a descending sort
Example
// Be careful : By default find Method only returns 100 A document
db.person.find()
db.person.insert({
name:'itzb', age:15})
db.person.find().limit(101)
db.person.find().sort({
age:1})
db.person.find().sort({
age:-1})
Be careful
3.1find Method will only fetch by default 100 A document
3.2sort The function always executes before the paging function
db.person.find().skip(5).limit(5)
db.person.find().skip(5).limit(5).sort({
age:-1})
code:
show databases;
use usser;
show collections;
db.person.find()
db.person.insertOne({
name:'itzb',age:12})
// Be careful : By default find Method only returns 100 A document
// Returns the specified quantity :
db.person.find().limit(500)
// Specify the ascending order of age
db.person.find().sort({
age:1}).limit(200)
// Specify the descending order of age
db.person.find().sort({
age:-1}).limit(200)
Be careful :sort Function if and limit,skip When used together , No matter what sort Before or after , Will execute first sort function
边栏推荐
- Call the computer calculator and use it to convert several base numbers
- 2022 recommended high-speed rail industry research report investment strategy industry development prospect market analysis (the attachment is a link to the online disk, and the report is continuously
- Leetcode simple question: judging the color of a grid on a chess board
- Haar cascades and LBP cascades in face detection [closed] - Haar cascades vs. LBP cascades in face detection [closed]
- 2022 recommended cloud computing industry research report investment strategy industry development prospect market analysis (the attachment is a link to the online disk, and the report is continuously
- The most complete machine learning model training process
- Maximum ascending subarray sum of leetcode simple problem
- JS messagechannel transport
- 3 frequently tested SQL data analysis questions (including data and code)
- The easiest GUI to compile: dgui
猜你喜欢

Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin

Purple red solid meso tetra (o-alkoxyphenyl) porphyrin cobalt (meso-t (2-rop) PCO) / tetra (n, n-diphenyl-p-amino) phenyl porphyrin (tdpatph2)

2022 recommended high-speed rail industry research report investment strategy industry development prospect market analysis (the attachment is a link to the online disk, and the report is continuously

Parsing rshub document auto generation API

Openfpga wishes you a happy Lantern Festival!

Pytest (7) -yield and termination function

5- (4-benzoimide phenyl) - 10,15,20-triphenylporphyrin (battph2) and its Zn complex (battpzn) / tetra (4-aminophenyl) porphyrin (tapph2) Qiyue supply
![[high concurrency] deeply analyze the callable interface](/img/17/93056547aa1a2b342e1b159b7c41c2.jpg)
[high concurrency] deeply analyze the callable interface

The simple problem of leetcode is to divide an array into three parts equal to sum

2022 recommended property management industry research report industry development prospect market investment analysis (the attachment is the link to the online disk, and the report is continuously up
随机推荐
Would like to ask, which is the better choice for securities companies? I don't understand. Is it safe to open an account online now?
ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
Common methods for describing 3D models of objects and their advantages and disadvantages
The simple problem of leetcode is to divide an array into three parts equal to sum
What has urbanization brought to our mental health and behavior?
Research Report on the new energy industry of recommended power equipment in 2022 industry development prospect market investment analysis (the attachment is a link to the network disk, and the report
Plugin
Hyperledger Fabric 2. X custom smart contract
想问问,券商选哪个比较好尼?本人小白不懂,现在网上开户安全么?
Leetcode notes on question brushing (XIV) -- related topics of binary tree attributes in binary tree chapter
Slot
2022.02.14
2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin copper (no2tmpp) Cu) /2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin (no2tmpp) H2) Qiyue porphyrin supply
5- (4-benzoimide phenyl) - 10,15,20-triphenylporphyrin (battph2) and its Zn complex (battpzn) / tetra (4-aminophenyl) porphyrin (tapph2) Qiyue supply
Embedded RTOS
Clickhouse data type
The first commercial spacewalk of mankind is finalized! Musk SpaceX announced a new round of space travel plan, and the American rich became repeat customers
The fresh student who was born in Ali after 2000: it's really fragrant to mend this
Difference between URI and URL
64 commonly used terms for data analysis, really all!