Are Lokijs ID's Unique?
Asked Answered
F

1

6

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

Featherweight answered 1/6, 2015 at 15:49 Comment(0)
R
9

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.

Resinate answered 2/6, 2015 at 5:29 Comment(1)
just to make sure, $loki values are assigned automatically?Hoist

© 2022 - 2024 — McMap. All rights reserved.