Unique Limitations - Google App Engine

Possible duplicate:
Unique Data Level Constraint in GAE

Does the Google App Datastore support unique restrictions?

+4
source share
2 answers

Not really, but the keys are guaranteed to be unique, and you can set the key of your entity as an arbitrary string. You can use this to create a unique key when saving an object to the data warehouse. For instance,

public class Entity implements Serializable { @Id String id; String unique_together_1; String unique_together_2; public Entity (String unique_together_1, String unique_together_2) { this.id = unique_together_1 + "-" + unique_together_2; this.unique_together_1 = unique_together_1; this.unique_together_2 = unique_together_2; } 

Obviously, this will not work if the unique fields of your object change later or if you need several unique restrictions for one type of entity.

+4
source

Source: https://habr.com/ru/post/1311942/


All Articles