Kaedah MongoDB Limit().


  Hasil terjemahan:

had

Bahasa Inggeris [ˈlɪmɪt] AS [ˈlɪmɪt]

n.had;

Kaedah MongoDB Limit().sintaks

Fungsi: Kaedah limit() menerima parameter angka yang menentukan bilangan rekod yang dibaca daripada MongoDB.

Sintaks: >db.COLLECTION_NAME.find().had(NUMBER)

Kaedah MongoDB Limit().contoh

集合 col 中的数据如下:

{ "_id" : ObjectId("56066542ade2f21f36b0313a"), "title" : "PHP 教程", "description" : "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。", "by" : "php中文网", "url" : "http://www.php.cn", "tags" : [ "php" ], "likes" : 200 }
{ "_id" : ObjectId("56066549ade2f21f36b0313b"), "title" : "Java 教程", "description" : "Java 是由Sun Microsystems公司于1995年5月推出的高级程序设计语言。", "by" : "php中文网", "url" : "http://www.php.cn", "tags" : [ "java" ], "likes" : 150 }
{ "_id" : ObjectId("5606654fade2f21f36b0313c"), "title" : "MongoDB 教程", "description" : "MongoDB 是一个 Nosql 数据库", "by" : "php中文网", "url" : "http://www.php.cn", "tags" : [ "mongodb" ], "likes" : 100 }
以上实例为显示查询文档中的两条记录:

> db.col.find({},{"title":1,_id:0}).limit(2)
{ "title" : "PHP 教程" }
{ "title" : "Java 教程" }
>

Cadangan popular

Rumah

video

Soal Jawab