I want to build a simple node.js backend that every time a customer makes a purchase creates an invoice number. The invoice number needs to be unique and sequential (1,2,3, ...) .
This seems simple enough, but I am a bit stuck hen it comes to storing this number securely and making sure there is no way I get duplicates.
Say my first invoice number is 1. I need to store this number somewhere, so that, when the next order comes in, I know that this order will have an invoice number of 2.
Is there a simple but secure way to store the last invoice number? I don't think I would need a full database table for this, as it's literally just one number? But I do need something reliable. Any advice?