Are Lokijs identifiers unique?

Is lokijs id ($ loki) unique?

if I have 2 documents from the same collection with $ loki: 1 and $ loki: 2 as id and I delete $ loki: 1, the next one I create should be $ loki: 3 ???

+5
source share
1 answer

It is right. Collections keep track of the last identifier that was created and assign the value a lastId + 1 to the $loki property of the next object that you insert into the collection. You can check the value of the last id by checking collection.maxId and print the next id by simply adding 1 to this.

+5
source

All Articles