Class: Entity

The base class for all entities

All Elixir model objects should inherit from this class. Statements can appear within the body of the definition of an entity to define its fields, relationships, and other options.

Here is an example:

class Person(Entity):
    name = Field(Unicode(128))
    birthdate = Field(DateTime, default=datetime.now)

Please note, that if you don't specify any primary keys, Elixir will automatically create one called id.

For further information, please refer to the provided examples or tutorial.

Methods

delete (self, *args, **kwargs)

expire (self, *args, **kwargs)

expunge (self, *args, **kwargs)

flush (self, *args, **kwargs)

session methods

from_dict (self, data)

Update a mapped class with data from a JSON-style nested dict/list structure.

get (cls, *args, **kwargs)

Return the instance of this class based on the given identifier, or None if not found. This is equivalent to: session.query(MyClass).get(...)

get_by (cls, *args, **kwargs)

Returns the first instance of this class matching the given criteria. This is equivalent to: session.query(MyClass).filter_by(...).first()

merge (self, *args, **kwargs)

refresh (self, *args, **kwargs)

save (self, *args, **kwargs)

save_or_update (self, *args, **kwargs)

only exist in SA < 0.5 IMO, the replacement (session.add) doesn't sound good enough to be added here. For example: "o = Order(); o.add()" is not very telling. It's better to leave it as "session.add(o)"

set (self, **kwargs)

to_dict (self, deep={}, exclude=[])

Generate a JSON-style nested dict/list structure from an object.

update (self, *args, **kwargs)

update_or_create (cls, data, surrogate=True)