千家信息网

MongoDB通过skip()方法来跳过limit指定数量的

发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,1.查看集合show collections2.向集合中添加数据db.runoob.insertMany([{'title':'data1','url':'https://blog.51cto.com
千家信息网最后更新 2025年02月03日MongoDB通过skip()方法来跳过limit指定数量的

1.查看集合

show collections

2.向集合中添加数据

db.runoob.insertMany([

{

'title':'data1',

'url':'https://blog.51cto.com/suyanzhu',

'description':'this is data1',

'view':5000

},

{

'title':'data2',

'url':'https://blog.51cto.com/suyanzhu',

'description':'this is data2',

'view':3650

},

{

'title':'data3',

'url':'https://blog.51cto.com/suyanzhu',

'description':'this is data3',

'view':9527

}

])

3.向集合添加数据

db.runoob.insert({

title: 222,

description: 'mongodb',

by: 'suyanzhu',

url: 'https://blog.51cto.com/suyanzhu',

tags: ['php','mongodb'],

likes: 200

})

4.查看所有数据

db.runoob.find().pretty()

5.返回指定行数数据

db.runoob.find().pretty().limit(2)

6.通过skip()方法来跳过limit指定数量的数据

db.runoob.find().pretty().limit(2).skip(2)

0