Model Attributes and Entity Properties

The App Engine datastore makes a distinction between an entity without a given property and an entity with a null value for a property. Slim3 Datastore does not support this distinction: every attribute of a model has a value, possibly null. If an attribute with a nullable value type (something other than a built-in type like int or boolean) is set to null, when the model is saved, the resulting entity will have the property set with a null value.

If a datastore entity is loaded into a model and doesn't have a property for one of the model's attirubutes and the attribute's type is a nullable single-value type, the attribute is set to null. When the model is saved back to the datastore, the null property becomes set in the datastore to the null value. If the attribute is not of a nullable value type, loading an entity without the corresponding property sets a default value to the attribute. This won't happen if the entity was created from the same model used to recreate the instance, but can happen if the model changes, or if the entity was created using the low-level API instead of Slim3 Datastore.

If the entity has a property that does not have a corresponding field in the model, that property is inaccessible from the model. If the model is saved back to the datastore, the extra property is deleted.


Continue to Keys and Entity Groups.