Last active
June 12, 2021 15:28
-
-
Save cassioeskelsen/fe47ee004a66f0803a6b1683db343718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_customer(key, value): | |
| if not value: | |
| return None | |
| elif key == "state": | |
| return State(**value) | |
| elif key == "address" and not isinstance(value, str): | |
| return Address(**value) | |
| if __name__ == "__main__": | |
| store = document_store.DocumentStore(urls=['http://localhost:8080'], database="python") | |
| store.conventions.mappers.update({Customer: get_customer}) | |
| store.initialize() | |
| customer = create_instance() | |
| with store.open_session() as session: | |
| session.store(customer) | |
| session.save_changes() | |
| with store.open_session() as session: | |
| c = session.load(customer.Id, Customer) | |
| print(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment