Skip to content

CLI | cli_api

ewolio edited this page Feb 10, 2020 · 5 revisions

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 Table

Overview

Members Documentation

EntityTable Attributes

  • __entity__: The class inheriting Entity managed by this table.

EntityTable Methods

  • getById(id)

    Retrieve one or some entities from the database's table. Note that table.getById(id) is similar to table[id].

    Parameters:
    • id [int|list|tuple|set]: One primary key or a list of primaries keys corresponding to the entities to retrieve.
    Return:

    If id is a primary key then returns the corresponding entity parsed as an object of type __entity__. Else, if id was a list, returns an EntityList of the parsed entities.

  • save(entity)

    Save an entity to the database.

    Parameters:
    • entity [Entity]: The entity to save.
  • delete(entity)

    Delete an entity .

    Parameters:
    • 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.

Inheriting EntityTable

Methods to override:

  • _getById(indexes)

  • _update(entity)

  • _update_multiples(entities)

  • _delete(id)

Useful decorators:

  • @cli_method

  • @format_entity(entity=None)

Entity

Overview

Members Documentation

Entity Attributes

Entity Methods

Extending Entity functionnalities

The json_template module

Entity List

Overview

Members Documentation

EntityList Attributes

EntityList Methods

Clone this wiki locally