const classafMongo::MongoSeqs
sys::Obj afMongo::MongoSeqs
(Service) - Creates sequential sequences of Ints
as an alternative to using BSON ObjectIds
.
A Mongo Collection stores the last ID created for sequences. An atomic findAndUpdate operation both increments and returns the relevant document.
By keeping the last IDs stored in the database it ensures the IDs are persisted between system restarts and that multiple clients can generate unique IDs.
While there is an overhead in generating new IDs, Int
IDs have the advantage of using less space in indexes, being easier to work with in web applications and they're generally nicer to look at!
- drop
Void drop()
Drops the
MongoSeqs
collection.- make
new make(MongoConnMgr connMgr, Str collName := "Seqs", Str? dbName := null)
Creates instance of
MongoSeqs
.- makeWithColl
new makeWithColl(MongoColl seqColl)
Creates instance of
MongoSeqs
with the given collection.- nextId
Returns the next
Int
ID for the given sequence name.- reset
Resets the last ID to zero.
- resetAll
Void resetAll()
Resets all the last IDs to zero.
- seqColl
const MongoColl seqColl
The Mongo Collection that stores the sequences.