An async ORM for DetaBase.
Project description
DetaORM
An async ORM for DetaBase.
Support | PyPI | Documentation
Example Usage
from __future__ import annotations
import asyncio
from detaorm import Client, Base, Field
class User(Base, name="users"):
username: Field[str] = Field()
nicknames: Field[list[str]] = Field(default=[])
async def main() -> None:
client = Client("<project key>", bases=[User])
await client.open()
new_user = User(username="CircuitSacul")
print(new_user) # > User({"username": "CircuitSacul"})
inserted_user = await new_user.insert()
print(inserted_user) # > User({"username": "CircuitSacul", "nicknames": []})
updated_user = await inserted_user.update(User.nicknames.append(["Circuit", "Sacul"]))
print(updated_user) # > User({"username": "CircuitSacul", "nicknames": ["Circuit", "Sacul"]})
page = await User.where(User.nicknames.contains("Sacul"), limit=1)
print(page.items[0]) # > User({"username": "CircuitSacul", "nicknames": ["Circuit", "Sacul"]})
if __name__ == "__main__":
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
detaorm-0.4.1.tar.gz
(8.9 kB
view details)
Built Distribution
detaorm-0.4.1-py3-none-any.whl
(11.5 kB
view details)
File details
Details for the file detaorm-0.4.1.tar.gz
.
File metadata
- Download URL: detaorm-0.4.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4424b62b6564453c0019e015bd449384f5573df7cd883abaf808bbbe7e8b67d |
|
MD5 | f6fb9325cf22f6d004a4444e7644e085 |
|
BLAKE2b-256 | f82b79e17f77a059d61e3031d7014506721a55357cae6667e25d0f50baa96033 |
File details
Details for the file detaorm-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: detaorm-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4410e9b386062c6a5c0941e7d3e438937af3b6103debfc1719632efb1b3fe5b9 |
|
MD5 | 51d31ba4152be92a2a5fdf8eb6adce6e |
|
BLAKE2b-256 | 6af57850642e4becca9e738d1dde77d33df514e6af2ac7e2ea00ace1609f9a7d |