How to set the start value of a hilo sequence in Normo MongoDB?

I imported a lot of existing values ​​into my mongodb through the normal driver (including the "old" id value is an integer). Now I have received repeated key errors from time to time.

To solve this problem, I have to manually set the initial value for the hilo sequence. How can I do that?

Thanks in advance

0
source share
1 answer

HiLo key information is stored in the NormHiLoKey collection. You can increase the value in this collection to change the initial value of the generated keys using the following command in the Mongo shell:

db.NormHiLoKey.update({ _id: "nameOfCollection" }, { $inc: { ServerHi: 42 } })

Attention

ServerHi Mongo! ServerHi 64- , . , , NoRM.

db.NormHiLoKey.find(), , , floatApprox. , 64- . $inc operator, .

+1

All Articles