mongospecs


Namemongospecs JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/jaykv/mongospecs
Summarysimple mongo ODM with support for msgspec, pydantic, and attrs
upload_time2024-12-16 04:17:57
maintainerNone
docs_urlNone
authorJay
requires_python<4.0,>=3.9
licenseNone
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
- *Spec adapters*
  - Build a spec out of existing BaseModels, attrs classes, or Structs
- *Raw BSON encode/decode for specs/mongo documents*
## Install
Choose from one of the following:
* `pip install mongospecs` for msgspec only
* `pip install mongospecs[pydantic]` for msgspec and pydantic only
* `pip install mongospecs[attrs]` for msgspec and attrs only
* `pip install mongospecs[pydantic,attrs]` for msgspec, pydantic, and attrs

### 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/mongospecs",
    "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/79/24/749cece3fcfd345b03e16995e2e0855d6b73c3269cdd9707ed9d8923e162/mongospecs-0.1.4.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- *Spec adapters*\n  - Build a spec out of existing BaseModels, attrs classes, or Structs\n- *Raw BSON encode/decode for specs/mongo documents*\n## Install\nChoose from one of the following:\n* `pip install mongospecs` for msgspec only\n* `pip install mongospecs[pydantic]` for msgspec and pydantic only\n* `pip install mongospecs[attrs]` for msgspec and attrs only\n* `pip install mongospecs[pydantic,attrs]` for msgspec, pydantic, and attrs\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\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "simple mongo ODM with support for msgspec, pydantic, and attrs",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/jaykv/mongospecs",
        "Repository": "https://github.com/jaykv/mongospecs"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10c71eb8f57e4a8fd8e0013d94b601fd0642b9a59f2e44b4f63219bf2525ad2f",
                "md5": "b37b336084f82919912366ee292e9ab1",
                "sha256": "23f2b0eb185d77b0d2f78a3d32cbda2163cef3cc9f8e8f3e391d04c0180fccee"
            },
            "downloads": -1,
            "filename": "mongospecs-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b37b336084f82919912366ee292e9ab1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 23682,
            "upload_time": "2024-12-16T04:17:55",
            "upload_time_iso_8601": "2024-12-16T04:17:55.084663Z",
            "url": "https://files.pythonhosted.org/packages/10/c7/1eb8f57e4a8fd8e0013d94b601fd0642b9a59f2e44b4f63219bf2525ad2f/mongospecs-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7924749cece3fcfd345b03e16995e2e0855d6b73c3269cdd9707ed9d8923e162",
                "md5": "b44180c8c9855d20f89be050a0316b45",
                "sha256": "2ed569b1bec03e265d56f206e9f674b603e3eeef83708647d1e03539db41265c"
            },
            "downloads": -1,
            "filename": "mongospecs-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b44180c8c9855d20f89be050a0316b45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 16968,
            "upload_time": "2024-12-16T04:17:57",
            "upload_time_iso_8601": "2024-12-16T04:17:57.404950Z",
            "url": "https://files.pythonhosted.org/packages/79/24/749cece3fcfd345b03e16995e2e0855d6b73c3269cdd9707ed9d8923e162/mongospecs-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-16 04:17:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jaykv",
    "github_project": "mongospecs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mongospecs"
}
        
Jay
Elapsed time: 0.40680s