This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a Base
CircuitSacul edited this page Sep 27, 2022
·
2 revisions
A "Base" is Deta's equivalent of an SQL "table". A Base is really just a list of dictionaries. To create a new Base, subclass detaorm.Base
:
from detaorm import Base
class MyBase(Base):
...
When creating a base, you can also define the bases name. If not specified, the base name will default to the class name (so "mybase" in this case).
...
class MyBase(Base, name="some_other_name"):
...
detaORM
bases work a lot like dataclasses. To add fields to your Base, you declare them as classvars, like this:
from detaorm import Base, Field
class MyBase(Base, name="some_other_name"):
my_field_name = Field()
If you like typehints, you can specify the field type like this:
...
my_field_name: Field[str] = Field()
Feel free to contribute to this wiki; Just try to follow the general idea use for other pages. (Also make sure to add any pages you create to the sidebar.)