Skip to main content

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


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.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

ormspace-0.1.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file ormspace-0.1.2.tar.gz.

File metadata

  • Download URL: ormspace-0.1.2.tar.gz
  • Upload date:
  • Size: 11.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

Hashes for ormspace-0.1.2.tar.gz
Algorithm Hash digest
SHA256 18849e63637ae8718296e05f5a52cc9fc4ac753e470330d39d49de839d9984a2
MD5 c5134ea1a773a570427583c3a4313d20
BLAKE2b-256 ceb5b21b0a67bb9bcc164349ddd2dfefcd0e820d9ede1bcfb4613bf73a2a3a81

See more details on using hashes here.

File details

Details for the file ormspace-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ormspace-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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

Hashes for ormspace-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13aa97ebae6d411b856e05b495a09f06149e7ab2d7af03012d241aa72cdb1f67
MD5 e382dcb9a4d3b399816f69a0287a6b9a
BLAKE2b-256 6c32a4a90dd3eba14f1bce301270a3c010ea4e79a5fb920227cff737ad3e6c03

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page