samuk190 / localbase

A Firebase-Style Database ... Offline!
649 stars 83 forks source link

How can we make the key auto incremented ? #9

Open KiranUppunda opened 3 years ago

KiranUppunda commented 3 years ago

Is it possible to make the key auto incremented on each insert ?

CynthiaBlue commented 3 years ago

I was just going to ask this exact same question!

BL2011 commented 2 years ago

I was just going to ask this exact same question!

Rednas83 commented 2 years ago

I have a requirement for this too.

As a workaround you can do:

if (!key) key=String(await this.$db.collection(table).get().length)
await this.$db.collection(table).add(iValue, key)

Possible solution await this.$db.collection(table).add(value) // Automaticly incrementing the key starting from 0 (replacing the generated key) resulting in image instead of image