Skip to content

mushkevych/synergy_odm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synergy Object-Document Mapping

PyPI version Build Status

Object Document Mapping for convenient python-to-json and json-to-python conversions

Usage example:

class SimpleContainer(BaseDocument):
    field_string = StringField()
    field_integer = IntegerField()
    field_boolean = BooleanField()
    field_datetime = DateTimeField()
    field_decimal = DecimalField()

class HostContainer(BaseDocument):
    nested_document = NestedDocumentField(SimpleContainer)
    field_list = ListField()
    field_dict = DictField()

... somewhere in the code ...
    model = HostContainer()
    model.field_dict['aaa'] = 'bbb'
    model.field_list.append('ccc')
    model.nested_document.field_boolean = True
    model.nested_document.field_string = 'a short string description'
    model.nested_document.field_datetime = datetime.now()
    model.nested_document.field_decimal = 123.123
    model.nested_document.field_integer = 123
    
    json_document = model.to_json()
    assert isinstance(json_data, dict)
    m2 = HostContainer.from_json(json_document)

Inspired by:

License:

BSD 3-Clause License.
Refer to LICENSE for details.

Git repository:

GitHub project page

Metafile:

/tests/               folder contains unit test
/odm/                 folder contains Object-Document Mapping modules

Test Runner

To run all tests from the tests directory, run following from the command line:

$> python -m unittest discover tests

Dependencies

  1. python 3.7+

About

Python Object <-> JSON mappings

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages