table
- class tinychain.collection.table.Schema(key, values=[])[source]
Bases:
objectA Table schema which comprises a primary key and value
Columns.
- class tinychain.collection.table.Table(form=None)[source]
Bases:
CollectionA Table defined by a primary key, values, and optional indices.
- aggregate(columns, fn)[source]
Apply the given callback to slices of this Table grouped by the given columns.
Returns a stream of tuples of the form (<unique column values>, <callback result>).
Example: orders.aggregate([“customer_id”, “product_id”], Table.count)
- insert(key, values=[])[source]
Insert the given row into this Table.
If the key is already present, this will raise a
BadRequesterror.
- order_by(columns, reverse=False)[source]
Set the order in which this Table’s rows will be iterated over.
If no index supports the given order, this will raise a
BadRequesterror.
- tinychain.collection.table.create_schema(modelclass: Type[Model]) Schema[source]
Create a table schema for the given model.
A key for the table is auto generated using the class_name function, then suffixed with ‘_id’. Each attribute of the model will be considered as a column if it is of type
ColumnorModel.