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 ???
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.
© 2022 - 2024 — McMap. All rights reserved.
$loki
values are assigned automatically? – Hoist