MongoDB DocumentStorePort adapter for muscles-data
Project description
muscles-data-mongodb
MongoDB adapter package for muscles-data.
This package is intentionally separate from muscles-data: the core package
owns typed ports and runtime, while this package owns the PyMongo-backed
DocumentStorePort adapter.
Related packages
- Core runtime and port contracts:
muscles-data - Elasticsearch search adapter:
muscles-data-elasticsearch - OpenSearch search adapter:
muscles-data-opensearch - Redis key-value/lock/stream adapter:
muscles-data-redis - Qdrant vector adapter:
muscles-data-qdrant - S3 object-store adapter:
muscles-data-s3 - SQLAlchemy direct SQL resource adapter:
muscles-data-sqlalchemy - Executable example:
example_data_mongodb_1
Install
python -m pip install muscles-data-mongodb
For local framework development:
PYTHONPATH=../muscles-data/src:src python3 -m pytest -q
Configuration
data:
resources:
mongo.content:
type: mongodb
url: ${MONGO_URL}
database: content
timeout: 3
max_limit: 100
Usage
Register the external factory in the project composition root:
from muscles_data.catalog import DataAdapterCatalog
from muscles_data.config import DataConfig
from muscles_data.ports import DocumentStorePort
from muscles_data.runtime import DataRuntime
from muscles_data_mongodb import MongoDocumentStoreFactory
catalog = DataAdapterCatalog.with_defaults()
catalog.register(MongoDocumentStoreFactory())
runtime = DataRuntime(config=DataConfig.from_raw(config), catalog=catalog)
store = runtime.require_port("mongo.content", DocumentStorePort)
Then use the narrow port:
store.upsert_document("profiles", "denis", {"name": "Denis"})
document = store.get_document("profiles", "denis")
documents = store.find_documents("profiles", filters={"role": "developer"}, limit=20)
store.delete_document("profiles", "denis")
The adapter maps document_id to MongoDB _id internally and returns public
documents without _id to keep the port backend-neutral.
Capabilities
MongoDocumentStoreFactory provides:
document_store;healthcheck;native_clientonly when the resource declaresnative_client: true.
Native access is an advanced project escape hatch:
from muscles_data import DataCapability
client = runtime.require_resource("mongo.content", DataCapability.NATIVE_CLIENT).native_client()
Use the native client for backend-specific aggregations, indexes or operations
that do not belong in DocumentStorePort.
Boundaries
This package owns:
- lazy PyMongo client creation;
- database binding;
- simple document get/find/upsert/delete;
- safe
inspect()anddoctor(); - bounded
find_documents()limits.
It does not own:
- ORM/document model layers;
- schema validation;
- migrations;
- complex aggregation abstraction;
- business repository APIs.
data.doctor performs a MongoDB ping. data.resources.list and package
initialization do not open a MongoDB connection.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file muscles_data_mongodb-0.1.1.tar.gz.
File metadata
- Download URL: muscles_data_mongodb-0.1.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd6102c92829c3f76aa3b6dbb4b4cb684a418c0623dabc7e9604bf293276eb2c
|
|
| MD5 |
38aa2d970a02df154cbfe841bbc0ea20
|
|
| BLAKE2b-256 |
22906869eca5948400a3412abbea6e0ff77d0b8c7b7378909a5fb6efed5719f0
|
Provenance
The following attestation bundles were made for muscles_data_mongodb-0.1.1.tar.gz:
Publisher:
release.yml on butkoden/muscles-data-mongodb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muscles_data_mongodb-0.1.1.tar.gz -
Subject digest:
bd6102c92829c3f76aa3b6dbb4b4cb684a418c0623dabc7e9604bf293276eb2c - Sigstore transparency entry: 2261286485
- Sigstore integration time:
-
Permalink:
butkoden/muscles-data-mongodb@88a70e46eecb7a4f5a642b2d832e94b4f6ed8b9e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/butkoden
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@88a70e46eecb7a4f5a642b2d832e94b4f6ed8b9e -
Trigger Event:
release
-
Statement type:
File details
Details for the file muscles_data_mongodb-0.1.1-py3-none-any.whl.
File metadata
- Download URL: muscles_data_mongodb-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
602f0253ef375613cbd200ddf9a948ef716526c3ec2f237c6013d37c0067719f
|
|
| MD5 |
83a9c50571e772a2d71d726d59ef82ab
|
|
| BLAKE2b-256 |
83523f1a2779b7d629e774a7e49b8f11eb1da6dfeb400fad7f8a1251c041a36a
|
Provenance
The following attestation bundles were made for muscles_data_mongodb-0.1.1-py3-none-any.whl:
Publisher:
release.yml on butkoden/muscles-data-mongodb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muscles_data_mongodb-0.1.1-py3-none-any.whl -
Subject digest:
602f0253ef375613cbd200ddf9a948ef716526c3ec2f237c6013d37c0067719f - Sigstore transparency entry: 2261286684
- Sigstore integration time:
-
Permalink:
butkoden/muscles-data-mongodb@88a70e46eecb7a4f5a642b2d832e94b4f6ed8b9e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/butkoden
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@88a70e46eecb7a4f5a642b2d832e94b4f6ed8b9e -
Trigger Event:
release
-
Statement type: