I am trying to learn NoSQL with Google Datastore but I am running into a problem with uniqueness.
Consider an ecommerce store, it has categories and products.
You do not want two products of the same SKU in the database.
So I insert an entity with JSON:
{"sku": 1234, "product_name": "Test product"}
And it shows up with two fields. But then I can do that again and I have two or more identical products.
How do you avoid this? Can you make the sku field unique?
Do I need to do a query before insert?
The same issue arises with categories. Should I just use one entity for ALL my categories and stucture it in my JSON?
What is a good common practice here?