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

Source

Void drop()

Drops the MongoSeqs collection.

make

Source

new make(MongoConnMgr connMgr, Str collName := "Seqs", Str? dbName := null)

Creates instance of MongoSeqs.

makeWithColl

Source

new makeWithColl(MongoColl seqColl)

Creates instance of MongoSeqs with the given collection.

nextId

Source

Int nextId(Str seqName)

Returns the next Int ID for the given sequence name.

reset

Source

Void reset(Str seqName)

Resets the last ID to zero.

resetAll

Source

Void resetAll()

Resets all the last IDs to zero.

seqColl

Source

const MongoColl seqColl

The Mongo Collection that stores the sequences.