I'm working on a Firebase application which will contain a set of codes, which are only available for one-time use, and will then be bound to a user permanently.
I want to achieve the best querying and updating capabilities on these codes, and following some recommendations from Firebase itself and previous questions I have come up with the following structure:
Codes
- Available
- 12345
- property 1
- property 2
- 32124
- property 1
- property 2
- Taken
- 23456
- property 1
- property 2
Users
- UID
- Codes
- 23456
This makes it so that querying available codes will be easy, as well as matching a code bound to a user with one of the taken codes (for verification after they log in).
The issue I'm having is, in order to move a code object from "Available" to "Taken", I have to delete it from the former and insert it into the later. Is this the right approach to take? I get nervous about physically deleting the data in order to move it.
Any advice on how to properly structure this use case?