A python orm with identity pattern mainly for arango
Project description
arorm
arango orm with identity pattern
examples
import typing
from arorm import ListProperty, Field, ObjectProperty, PasswordField, Model, ReferenceId, Reference, ReferenceIdList, ReferenceList, Store, RemoteReferenceList
class UserAttributes(ObjectProperty):
class Settings(ObjectProperty):
notifications = Field(default=False)
html5Notifications = Field(default=False)
last_update: float = Field(default=0)
last_login: float = Field(default=0)
settings = Settings()
class User(Model):
__collection__ = 'users'
name = Field()
password = PasswordField(hidden=True)
email = Field()
attributes = UserAttributes()
achievements: typing.List[str] = ListProperty(str)
books: typing.List['Book'] = RemoteReferenceList('author_id', 'Book')
class Book(Model):
__collection__ = 'books'
author_id = ReferenceId()
author = Reference(author_id, User)
co_authors_ids = ReferenceIdList()
co_authors: typing.List[User] = ReferenceList(co_authors_ids, User)
db = dict(host='127.0.01', user='root', password='root', port=8529, driver='arango')
store = Store(db)
store.setup_db()
user = store.create(User) # will create a user on commit
book = store.create(Book) # will create a book on commit
book.author = user
book.co_authors.append(user)
store.query(User).filter(User.name == 'admin').delete() # queued to be executed on commit
store.run_after_commit(lambda: print('did commit'))
store.commit()
user.to_json() # -> will now have _id, _rev
book.to_json() # -> will now have author_id set to same id as user
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
arorm-0.3.3.tar.gz
(10.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
arorm-0.3.3-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file arorm-0.3.3.tar.gz.
File metadata
- Download URL: arorm-0.3.3.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c4c2abd3f2f17b7797146781c6e1398a47d087866af92bb00413da6c1a883e
|
|
| MD5 |
3281cd3b7c55d677d7fb506d01c82b00
|
|
| BLAKE2b-256 |
d5b29e614ebbf9254f9e3e0f482944c876947917bb56e2e3c2a42e61e54973fe
|
File details
Details for the file arorm-0.3.3-py3-none-any.whl.
File metadata
- Download URL: arorm-0.3.3-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
775694cee0ddc157eb9424fdbf341455a2e162cd6334b108bdc60f6338c16d6c
|
|
| MD5 |
02095a845c28f26c2bd54e38fce5734c
|
|
| BLAKE2b-256 |
de07962fffd4ad251e96f467eb95e557623b2c8a37bf3ecde75507c814534c3c
|