limit
UK[?l?m?t] US[?l?m?t]
n.limit;limit;limit,limit
vt.limit,limit
MongoDB Limit() method syntax
Function: The limit() method accepts a numeric parameter that specifies the number of records read from MongoDB.
Syntax: >db.COLLECTION_NAME.find().limit(NUMBER)
MongoDB Limit() method example
集合 col 中的數(shù)據(jù)如下: { "_id" : ObjectId("56066542ade2f21f36b0313a"), "title" : "PHP 教程", "description" : "PHP 是一種創(chuàng)建動態(tài)交互性站點的強有力的服務(wù)器端腳本語言。", "by" : "php中文網(wǎng)", "url" : "http://miracleart.cn", "tags" : [ "php" ], "likes" : 200 } { "_id" : ObjectId("56066549ade2f21f36b0313b"), "title" : "Java 教程", "description" : "Java 是由Sun Microsystems公司于1995年5月推出的高級程序設(shè)計語言。", "by" : "php中文網(wǎng)", "url" : "http://miracleart.cn", "tags" : [ "java" ], "likes" : 150 } { "_id" : ObjectId("5606654fade2f21f36b0313c"), "title" : "MongoDB 教程", "description" : "MongoDB 是一個 Nosql 數(shù)據(jù)庫", "by" : "php中文網(wǎng)", "url" : "http://miracleart.cn", "tags" : [ "mongodb" ], "likes" : 100 } 以上實例為顯示查詢文檔中的兩條記錄: > db.col.find({},{"title":1,_id:0}).limit(2) { "title" : "PHP 教程" } { "title" : "Java 教程" } >