Are lokijs id's ($loki) unique?
if I have 2 documents from one collection with $loki:1 and $loki:2 as id's, and I delete $loki:1, the next one I create should it be $loki:3 ???
That's correct. Collections keep track of the last ID that was created and assign the a lastId + 1
value to the $loki
property of the next object you insert in a collection. You can check the value of the last id by checking collection.maxId
and deduce the next id by simply adding 1 to that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With