4.12.1Class DBEntity

Database entity.

Class DBEntity( dbm )
dbm The database manager to which this enitity is related

This class represents a table, or anyhow an entity type in a persistent storage system.

New site-specific entities must be placed in files under nest/dm/dbname named after the class they hold. For example, a "Users" entity should be placed in a class named "class Users", which should have its own file named nest/dm/dbname/Users.fal.

The implementations must specify a definition property and store the entity definition into it.

Each element of the definition property should be a string where the first word is a field name, and the rest is a field definition that can be applied by the Nest users should extend this class to describe the actual entities in their databases.

Elements of the definition array meant to be part of the key of this field should must be declared as OOB (i.e. ^+ "id integer not null")

The name under which the entity is known is defaulted to the class name, but subclasses may override the "name" property in their init method, if this is not desired.

Properties
init_dataInitial data for this entity.
nameName of this entity as known in the database system. By default, the name is set to the name of the class, but it may be overridden by specifying the name property in the subclass.
Methods
eidReturns a key expression identifying this record. A string representing a valid key identifying this record.
parseKeyBreaks a string key in a dictionary of values for the key files.

Properties

init_data

Initial data for this entity.

Must be a dictionary of "field name" => value.

Used by the data-manager when creating the entity to fill the initial values.

Leave nil if not used.

name

Name of this entity as known in the database system. By default, the name is set to the name of the class, but it may be overridden by specifying the name property in the subclass.

Methods

eid

Returns a key expression identifying this record. A string representing a valid key identifying this record.

eid()

The returned string has the format of "key_val1|key_val2|...|key_valn"; inbound "|" in keys are escaped to "\|", so that it is possible to rebuild the original key values by splitting the returned value.

parseKey

Breaks a string key in a dictionary of values for the key files.

parseKey( kval )
kval A key expression generated by DBRecord.key.
ReturnA dictionary of [key_fields => values] suitable to be used to find the record indicated by kval.
Made with http://www.falconpl.org