Name | mongospecs JSON |
Version |
0.1.0
JSON |
| download |
home_page | https://github.com/jaykv/mongospec |
Summary | simple mongo ODM with support for msgspec, pydantic, and attrs |
upload_time | 2024-05-02 06:52:05 |
maintainer | None |
docs_url | None |
author | Jay |
requires_python | <4.0,>=3.9 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# mongospecs
Built on top of the https://github.com/GetmeUK/MongoFrames ODM, with:
- Pydantic (`BaseModel`), attrs (`@define`), and msgspec (`Struct`) support for defining schema models (specs)
- Type-hints
### Example
```python
# Import Spec, either...
## 1. with pydantic:
from mongospecs.pydantic import Spec
## 2. with msgspec:
from mongospecs.msgspec import Spec
## 3. with attrs:
from mongospecs.attrs import Spec
# Define schema model
class Dragon(Spec):
_collection = "dragons" # Optional. If not defined, uses the class name by default.
name: str
breed: Optional[str] = None
# create
burt = Dragon(name="Burt", breed="Cold-drake")
print(burt.name) # Burt
print(burt.breed) # Cold-drake
# insert
burt.insert()
print(burt.id) # inserted document ObjectId
# fetch
doc = Dragon.find_one({"name": "Burt"}) # returns raw mongo document
# delete
burt.delete()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/jaykv/mongospec",
"name": "mongospecs",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Jay",
"author_email": "jay.github0@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/89/78/ba40db8894352b5a1427d4bc5190e14c6618e06b5ba210f74003914e9c1c/mongospecs-0.1.0.tar.gz",
"platform": null,
"description": "# mongospecs\n\nBuilt on top of the https://github.com/GetmeUK/MongoFrames ODM, with:\n- Pydantic (`BaseModel`), attrs (`@define`), and msgspec (`Struct`) support for defining schema models (specs)\n- Type-hints\n\n\n### Example\n```python\n# Import Spec, either...\n## 1. with pydantic:\nfrom mongospecs.pydantic import Spec\n\n## 2. with msgspec:\nfrom mongospecs.msgspec import Spec\n\n## 3. with attrs:\nfrom mongospecs.attrs import Spec\n\n# Define schema model\nclass Dragon(Spec):\n _collection = \"dragons\" # Optional. If not defined, uses the class name by default.\n\n name: str\n breed: Optional[str] = None\n\n# create\nburt = Dragon(name=\"Burt\", breed=\"Cold-drake\")\nprint(burt.name) # Burt\nprint(burt.breed) # Cold-drake\n\n# insert\nburt.insert()\nprint(burt.id) # inserted document ObjectId\n\n# fetch\ndoc = Dragon.find_one({\"name\": \"Burt\"}) # returns raw mongo document\n\n# delete\nburt.delete()\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "simple mongo ODM with support for msgspec, pydantic, and attrs",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/jaykv/mongospec",
"Repository": "https://github.com/jaykv/mongospec"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "afb4ae9e350182c23da13d63c06d26f6e06b14ed929210894afd59950d736426",
"md5": "c5f414600aaeae1ced92b20914670eba",
"sha256": "aa8e29d7bbcfe5f5501694654ce3e1e3b383e33b989c6d00735e7d9e66939342"
},
"downloads": -1,
"filename": "mongospecs-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c5f414600aaeae1ced92b20914670eba",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 17701,
"upload_time": "2024-05-02T06:52:03",
"upload_time_iso_8601": "2024-05-02T06:52:03.072621Z",
"url": "https://files.pythonhosted.org/packages/af/b4/ae9e350182c23da13d63c06d26f6e06b14ed929210894afd59950d736426/mongospecs-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8978ba40db8894352b5a1427d4bc5190e14c6618e06b5ba210f74003914e9c1c",
"md5": "4d22fa5304ccd8c4330a77b2a28113ce",
"sha256": "061762bde99c40e460384c54f62a1995e921ad25749f14d204828bc280e3cafa"
},
"downloads": -1,
"filename": "mongospecs-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "4d22fa5304ccd8c4330a77b2a28113ce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 14432,
"upload_time": "2024-05-02T06:52:05",
"upload_time_iso_8601": "2024-05-02T06:52:05.060165Z",
"url": "https://files.pythonhosted.org/packages/89/78/ba40db8894352b5a1427d4bc5190e14c6618e06b5ba210f74003914e9c1c/mongospecs-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-02 06:52:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jaykv",
"github_project": "mongospec",
"github_not_found": true,
"lcname": "mongospecs"
}