Reputation: 125
I'm trying to build an invoice system for a client of mine using Vue.js and Cloud Firestore.
Once a new invoice is created, my client wants an auto generated invoice number added to every new invoice starting from 0001, 0002, 0003 etc... I guess it would be a numerical ID for every new invoice.
How would i go about doing this with Cloud Firestore? I was looking into the new firebase function:
firebase.firestore.FieldValue.increment()
but its not exactly what i was looking for. Or maybe i'm not using it correctly?
I've been going crazy trying to find a solution or even an idea that would steer me in the right direction.
Thank You!
Upvotes: 1
Views: 565
Reputation: 125
I was able to solve this another way. I created a document (--invoices--) and in that document i created a field called count and im using the increment function to add to that count when a new document is created.
firebase.firestore.FieldValue.increment()
So, when that count gets updated i grab the last number and update the invoice number field on the new document that was created.
Upvotes: 2