Skip to content

TileORM

An ORM for Tile38. Inspired by Peewee. Validated by Pydantic.
from tileorm import CharField, Group, Identifier, Model, Point, PointField, Tile38
db = Tile38("redis://localhost:9851")
class Truck(Model):
id: int = Identifier()
group: str = Group()
field: str = CharField()
location: Point = PointField()
class Meta:
database = db
truck = await Truck.create(
id=1,
group="fleet1",
location=Point(lat=52.25, lon=13.37),
field="value",
)
truck = await Truck.get(id=1, group="fleet1")
# Truck(id=1, location=Point(lat=52.25, lon=13.37), group='fleet1', field='value')

Models, not raw commands

Define a Tile38 object as a Pydantic model. TileORM turns field values into SET, GET, SCAN, and NEARBY commands for you.

Validated fields

Pydantic validates every field on the way in and out, including geo types like Point and Bounds.

Async queries

create, get, find, and nearby are async methods that return model instances, not raw JSON.

Small surface area

One Model base class, a handful of field types, and a small set of exceptions. Read the guides in a sitting.