![]() |
Model subclass to support dynamic Property names and types.
Inherits From: Model
, expected_type
google.appengine.ext.ndb.Expando(
*args, **kwds
)
See the module docstring for details.
Attributes | |
---|---|
key
|
Special property to store the Model key. |
Methods
allocate_ids
@classmethod
allocate_ids( size=None, max=None, parent=None, **ctx_options )
Allocates a range of key IDs for this model class.
Args | |
---|---|
size
|
Number of IDs to allocate. Either size or max can be specified, not both. |
max
|
Maximum ID to allocate. Either size or max can be specified, not both. |
parent
|
Parent key for which the IDs will be allocated. |
**ctx_options
|
Context options. |
Returns | |
---|---|
A tuple with (start, end) for the allocated range, inclusive. |
allocate_ids_async
@classmethod
allocate_ids_async( size=None, max=None, parent=None, **ctx_options )
Allocates a range of key IDs for this model class.
This is the asynchronous version of Model._allocate_ids().
get_by_id
@classmethod
get_by_id( id, parent=None, **ctx_options )
Returns an instance of Model class by ID.
This is really just a shorthand for Key(cls, id, ...).get().
Args | |
---|---|
id
|
A string or integer key ID. |
parent
|
Optional parent key of the model to get. |
namespace
|
Optional namespace. |
app
|
Optional app ID. |
**ctx_options
|
Context options. |
Returns | |
---|---|
A model instance or None if not found. |
get_by_id_async
@classmethod
get_by_id_async( id, parent=None, app=None, namespace=None, **ctx_options )
Returns an instance of Model class by ID (and app, namespace).
This is the asynchronous version of Model._get_by_id().
get_or_insert
@classmethod
get_or_insert( *args, **kwds )
Transactionally retrieves an existing entity or creates a new one.
Positional Args:
name
: Key name to retrieve or create.
Keyword Args:
namespace
: Optional namespace.app
: Optional app ID.parent
: Parent entity key, if any.context_options
: ContextOptions object (not keyword args!) or None.**kwds
: Keyword arguments to pass to the constructor of the model class if an instance for the specified key name does not already exist. If an instance with the supplied key_name and parent already exists, these arguments will be discarded.
Returns | |
---|---|
Existing instance of Model class with the specified key name and parent or a new one that has just been created. |
get_or_insert_async
@classmethod
get_or_insert_async( *args, **kwds )
Transactionally retrieves an existing entity or creates a new one.
This is the asynchronous version of Model._get_or_insert().
gql
@classmethod
gql( query_string, *args, **kwds )
Run a GQL query.
has_complete_key
has_complete_key()
Return whether this entity has a complete key.
populate
populate(
**kwds
)
Populate an instance from keyword arguments.
Each keyword argument will be used to set a corresponding property. Keywords must refer to valid property name. This is similar to passing keyword arguments to the Model constructor, except that no provisions for key, id or parent are made.
put
put(
**ctx_options
)
Write this entity to Cloud Datastore.
If the operation creates or completes a key, the entity's key attribute is set to the new, complete key.
Returns | |
---|---|
The key for the entity. This is always a complete key. |
put_async
put_async(
**ctx_options
)
Write this entity to Cloud Datastore.
This is the asynchronous version of Model._put().
query
@classmethod
query( *args, **kwds )
Create a Query object for this class.
Args | |
---|---|
distinct
|
Optional bool, short hand for group_by = projection. |
*args
|
Used to apply an initial filter |
**kwds
|
are passed to the Query() constructor. |
Returns | |
---|---|
A Query object. |
to_dict
to_dict(
include=None, exclude=None
)
Return a dict containing the entity's property values.
Args | |
---|---|
include
|
Optional set of property names to include, default all. |
exclude
|
Optional set of property names to skip, default none. A name contained in both include and exclude is excluded. |
__eq__
__eq__(
other
)
Compare two entities of the same class for equality.
__ne__
__ne__(
other
)
Implement self != other as not(self == other).