Skip to content

Commit 4cbcb6b

Browse files
committed
Update README.md
1 parent c21c601 commit 4cbcb6b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,21 @@ db.inventory.find({ pictures: { $exists: true, $ne: [] } })
15011501
<b><a href="#">↥ back to top</a></b>
15021502
</div>
15031503
1504-
#### Q. ***How to get the last N records from find?***
1504+
## Q. ***How to get the last N records from find?***
1505+
1506+
```js
1507+
// Syntax
1508+
db.<CollectionName>.find().sort({$natural:-1}).limit(value)
1509+
1510+
1511+
// Example
1512+
db.employee.find().sort({$natural:-1}).limit(100)
1513+
```
1514+
1515+
<div align="right">
1516+
<b><a href="#">↥ back to top</a></b>
1517+
</div>
1518+
15051519
#### Q. ***Explain relationships in mongodb?***
15061520
#### Q. ***What is use of capped collection in MongoDB?***
15071521

0 commit comments

Comments
 (0)