Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Lokijs ID's Unique?

Tags:

lokijs

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 ???

like image 852
Pedro Luz Avatar asked Jun 01 '15 15:06

Pedro Luz


1 Answers

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.

like image 187
Joe Minichino Avatar answered Oct 23 '22 02:10

Joe Minichino