This is an introduction to ArangoDB's size restrictions aka cap for collections.
It is possible to restrict the size of collection. If you add a document and the size exceeds the limit, then the least recently created or updated document will be dropped.
collection.ensureCapConstraint(size)
Note that at most one cap constraint is allowed per collection.
Note that the collection should be empty. Otherwise the behavior is undefined, i. e., it is undefined which documents will be removed first.
Note that this does not imply any restriction of the number of revisions of documents.
Examples
Restrict the number of document to at most 10 documents:
arango> db.examples.ensureCapConstraint(10); { "id" : "147879/934311", "type" : "cap", "size" : 10, "isNewlyCreated" : true } arango> for (var i = 0; i < 20; ++i) { var d = db.examples.save( { n : i } ); } arango> db.examples.count(); 10