{"id":13770056,"url":"https://github.com/datastore/datastore.objects","last_synced_at":"2025-05-11T02:34:58.161Z","repository":{"id":6965940,"uuid":"8218581","full_name":"datastore/datastore.objects","owner":"datastore","description":"object mapper for datastore","archived":false,"fork":false,"pushed_at":"2013-08-17T02:29:57.000Z","size":191,"stargazers_count":6,"open_issues_count":4,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-22T06:00:11.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datastore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-15T13:17:01.000Z","updated_at":"2023-08-11T22:41:09.000Z","dependencies_parsed_at":"2022-09-03T09:41:30.931Z","dependency_job_id":null,"html_url":"https://github.com/datastore/datastore.objects","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastore%2Fdatastore.objects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastore%2Fdatastore.objects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastore%2Fdatastore.objects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastore%2Fdatastore.objects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datastore","download_url":"https://codeload.github.com/datastore/datastore.objects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253507330,"owners_count":21919194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:00:33.910Z","updated_at":"2025-05-11T02:34:57.907Z","avatar_url":"https://github.com/datastore.png","language":"Python","readme":"# datastore.objects\n\n[`datastore.objects`](https://github.com/datastore/datastore.objects) is a\nsimple *object mapper* on top of\n[`datastore`](https://github.com/jbenet/datastore) (not relational). Thanks to\ndatastore's versatility, it makes it easy to (serialize and) persist custom\nclasses to any sort of data storage service.\n\nNotice: please familiarize yourself with `datastore` first.\n\n## Install\n\n\n    pip install datastore.objects\n\n\n## Interface\n\n### Key\n\n`datastore.objects` uses the default `datastore.Key`, making significant use\nof the `type` and `instance` fragments.\n\n```python\n\u003e\u003e\u003e from datastore.objects import Key, Model\n\u003e\u003e\u003e class Scientist(Model):\n\u003e\u003e\u003e   pass\n\u003e\u003e\u003e Scientist.key\nKey('/Scientist')\n\u003e\u003e\u003e Scientist('Tesla').key\nKey('/Scientist:Tesla')\n```\n\n\n### Model\n\n`datastore.objects` provides a class that you inherit from to define your\nmodels. datastore.objects.Model handles the datastore serializing and\ndeserializing, attribute validation, etc.\n\n```python\n\u003e\u003e\u003e from datastore.objects import Model\n\u003e\u003e\u003e class Scientist(Model):\n\u003e\u003e\u003e   pass\n```\n\n\n### Attribute\n\n`datastore.objects` uses descriptor Attributes to track the properties you wish\nto store. This is heavily based on how other python ORMs (django, app engine)\ndo it. In short, you define model attributes like this:\n\n\n```python\n\u003e\u003e\u003e from datastore.objects import Attribute, Model\n\u003e\u003e\u003e class Scientist(Model):\n\u003e\u003e\u003e   name = Attribute(required=True)\n\u003e\u003e\u003e   field = Attribute(default='Physics')\n\u003e\u003e\u003e tesla = Scientist('Tesla')\n\u003e\u003e\u003e tesla.name = 'Nicola Tesla'\n\u003e\u003e\u003e tesla.field\n'Physics'\n\u003e\u003e\u003e tesla.field = 'Electrical Engineering'\n\u003e\u003e\u003e tesla.data\n{'name': 'Nicola Tesla', 'field': 'Electrical Engineering'}\n```\n\n### ObjectDatastore\n\n`datastore.objects` provides a `ShimDatastore` that wraps any other datastore.\nThus you can use any of the various datastores to persist your objects.\n`ObjectDatastore` makes sure to serialize (on put) and deserialize (on get)\ndata properly, and construct your classes.\n\n```python\n\u003e\u003e\u003e import datastore\n\u003e\u003e\u003e from datastore.objects import Attribute, Model, ObjectDatastore\n\u003e\u003e\u003e\n\u003e\u003e\u003e class Scientist(Model):\n\u003e\u003e\u003e   name = Attribute(required=True)\n\u003e\u003e\u003e   field = Attribute(default='Physics')\n\u003e\u003e\u003e\n\u003e\u003e\u003e tesla = Scientist('Tesla')\n\u003e\u003e\u003e tesla.name = 'Tesla'\n\u003e\u003e\u003e tesla.field = 'Electrical Engineering'\n\u003e\u003e\u003e\n\u003e\u003e\u003e dds = datastore.DictDatastore()\n\u003e\u003e\u003e ods = ObjectDatastore(dds, model=Scientist)\n\u003e\u003e\u003e ods.put(tesla.key, tesla)\n\u003e\u003e\u003e dds.get(tesla.key)\n{'name': 'Tesla', 'field': 'Electrical Engineering'}\n\u003e\u003e\u003e ods.get(tesla.key)\n\u003cModel /Scientist:Tesla\u003e\n```\n\n\n## About\n\n#### Author\n\n`datastore.objects` is written by [Juan Batiz-Benet](https://github.com/jbenet),\nof [Athena](http://athena.ai).\n\n#### License\n\nIt is free open-source software, available under\nthe MIT License.\n\n#### Contact\n\nProject webpage: https://github.com/datastore/datastore.objects.\nIssues: https://github.com/jbenet/object-datastore/issues\n","funding_links":[],"categories":["Model, Schema"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatastore%2Fdatastore.objects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatastore%2Fdatastore.objects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatastore%2Fdatastore.objects/lists"}