Pydantic models working with deta.space api, including ORM features.
Project description
ormspace
ORM modules powered by Pydantic for Deta Space.
Instructions
The package ormspace will use the deta data key provides as COLLECTION_KEY or will look for DETA_PROJECT_KEY if the first is not provided. This way you can set a custom data key or use the project default. The sistem cannot work all is missing.
the 'modelmap' decorator
To include the class in the system mapping you must use the 'modelmap' decorator. With this procedure you will get:
- access to deta space api for read and write your data
- create special fields for each class:
- Model.Key
- Model.KeyList
Example
import datetime
import asyncio
from ormspace import model as md
@md.modelmap
class Person(md.Model):
first_name: str
last_name: str
birth_date: datetime.date
@md.modelmap
class Patient(md.Model):
person_key: Person.Key
async def main():
await Patient.update_references_context()
for item in await Patient.sorted_instances_list():
print(item)
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ormspace-0.1.5.tar.gz
(13.3 kB
view details)
Built Distribution
ormspace-0.1.5-py3-none-any.whl
(15.9 kB
view details)
File details
Details for the file ormspace-0.1.5.tar.gz
.
File metadata
- Download URL: ormspace-0.1.5.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.18 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fabe92acb31e4585225ceb7af91bbbda7844d5d6d2ea05008d356937b2755342 |
|
MD5 | a7dee95360084247310492f9478dd532 |
|
BLAKE2b-256 | 0869e1925266ae4013f6841f0fafaf4388c3248f9d2b89504d29733000a15262 |
File details
Details for the file ormspace-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: ormspace-0.1.5-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.18 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | caff88f802873e09a8bf9ebe9ca9b229f68917a84ec7b6725dfcc66d2dbd19a8 |
|
MD5 | e8e3f4c8d29ad27a1438e6d690c06269 |
|
BLAKE2b-256 | 1f33c58be2db1648e50f89bcdf98a09fea86158233560c04087d62d74a9ed1b8 |