Metadata-Version: 2.1
Name: mongospecs
Version: 0.1.0
Summary: simple mongo ODM with support for msgspec, pydantic, and attrs
Home-page: https://github.com/jaykv/mongospec
Author: Jay
Author-email: jay.github0@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: blinker (>=1.6.3,<2.0.0)
Requires-Dist: methodtools (>=0.4.7,<0.5.0)
Requires-Dist: msgspec (>=0.18.4,<0.19.0)
Requires-Dist: pymongo (>=4.5.0,<5.0.0)
Requires-Dist: typing-extensions (>=4.8.0,<5.0.0)
Project-URL: Repository, https://github.com/jaykv/mongospec
Description-Content-Type: text/markdown

# 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()
```
