-
Notifications
You must be signed in to change notification settings - Fork 0
CLI | cli_api
The cli_api library allows managing of the database by adding, updating, deleting entries, by displaying its content and by providing higher-level functionalities (automatic tasks creation, ...).
To every table in the database correspond an EntityTable in the cli_api. Those different tables are stored in the cli_api.cli object. Even though their classes are different (UserTable, ImageTable...), all of them inherit the same class EntityTable. This class defines common functionalities, mainly requesting data to the server and parsing them into Entity or EntityList.
-
__entity__: The class inheritingEntitymanaged by this table.
-
Retrieve one or some entities from the database's table. Note that
table.getById(id)is similar totable[id].-
id [int|list|tuple|set]: One primary key or a list of primaries keys corresponding to the entities to retrieve.
If
idis a primary key then returns the corresponding entity parsed as an object of type__entity__. Else, ifidwas a list, returns anEntityListof the parsed entities. -
-
Save an entity to the database. Alternatively, you can use
entity.save().-
entity [Entity]: The entity to save.
-
-
Delete an entity . Alternatively you can use
del table[id]whereidis the index in the database of the entity to delete.-
entity [Entity|int|list|tuple|set]: An entity to delete or its a primary key. A list of those is also accepted, in this case they will be deleted one after the other.
-
Methods to override:
Useful decorators:
Entity automatically parses prototype from models of the server (e.g. ProtoImage or ProtoUser).
-
Save this entity to the database.
-
Revert this entity to its state in the database.
-
Delete this entity from the database.
-
Inherited from
json_template.JSONClass.Export the entity to JSON format (compatible with
Protoformat of entities in the database).
Methods to override:
- A class method returning the table singleton corresponding to this entity.