Closed kypanz closed 2 years ago
Can you be more specific of what you mean by auto increment?
I am assuming you are talking about the ID increasing as you add more entries. If you are adding all the entries at the time, you can increment the ID of each entry in a for loop. Or if you are trying to randomly add a new entry, first you would need to find out whats the last entry ID, store.get()
(process in between to check for the last entry) then increment based off the last entry.
Hello i have a idea how to do this , but i think my idea is not the best way ( i really dont know how to do this, but i trying )
example of code : https://pastebin.com/unKXLKS4
i take the length of the entrys with this line :
var count = Object.keys(db._index._index).length;
but i think is not the way to do this.
can you give me a example to use store.get ? , thanks a lot for the answer
Honestly, that's the best way to do it. The object is already on the heap and it will generally return the correct value. You'll need to make sure to continue calling db.load()
as you're doing it to keep the in-memory value up to date.
thanks a lot guys for the fast answers, have a good day <3, i go to keep learning orbit db
Hello i have a question , i wanna do something like this but with the _id in auto increment with docstore, i really dont know how to do that, i see the documentation but in all examples i see a _id predefined, somebody can help me please , thanks a lot <3
{ _id: 'X', name: 'kypanz', country: 'chile' }