Return limited number of records of a certain type, but unlimited number of other records?

前端 未结 4 1302
清酒与你
清酒与你 2020-12-20 02:16

I have a query where I need to return 10 of \"Type A\" records, while returning all other records. How can I accomplish this?

Update: Admittedly, I

4条回答
  •  甜味超标
    2020-12-20 02:47

    i guess you can use cursor.limit() on a cursor to specify the maximum number of documents the cursor will return. limit() is analogous to the LIMIT statement in a SQL database. You must apply limit() to the cursor before retrieving any documents from the database.

    The limit function in the cursors can be used for limiting the number of records in the find.

    I guess this example should help:

    var myCursor = db.bios.find( );
    
    db.bios.find().limit( 5 )
    

提交回复
热议问题