Reputation: 843
I'm using mongodb with c# driver, and I would like to limit my MongoCollection to maximum 1 row. How do I do that ?
Upvotes: 1
Views: 778
Reputation: 6075
Since this is tagged as mongodb-csharp, FindOneAs or SetLimit may be helpful:
https://stackoverflow.com/a/6593345/284598
Upvotes: 0
Reputation: 311875
If you want to limit the collection itself to one row, you could use a capped collection with max: 1
.
db.createCollection("mycoll", {capped:true, size:100000, max:1});
Upvotes: 1