feat(standards): codify codegen, ship generic Tier-B infra, add get_app_template + prompts; fix docs:// regressions
P0: fix doc:// -> docs:// across standards src/server/registry and regenerate stale mongo-ops bundle. P1: build recipe + spec-first routing now document the openapi-first codegen fast path (models/routes with --inject-request/--package). P4: CRUD template documents the model-vs-document id rule (BaseDocument owns id). P5: authless guidance (omit security keys). P6: template gains generic infra (http_cache, keyed SSE bus, KV port+in-memory+Redis), interfaces/openapi.py + .dockerignore + generic build test registered as components, and a get_app_template tool; genericity matrix marks LLM pool + human-in-loop as reference-app patterns. P7: intake/build/start_app/trial prompts. P8: template ships tests/integration/test_openapi_app_builds.py. Rebuilt standards + openapi-first bundles and re-collected.
This commit is contained in:
@@ -2,119 +2,49 @@
|
||||
"module": "mongo_ops.repository",
|
||||
"content": {
|
||||
"path": "mongo_ops.repository",
|
||||
"docstring": "Repository patterns and CRUD mixins for MongoDB.",
|
||||
"docstring": "# Summary\n\nRepository patterns and CRUD mixins for MongoDB.",
|
||||
"objects": {
|
||||
"datetime": {
|
||||
"name": "datetime",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.datetime",
|
||||
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Dict": {
|
||||
"name": "Dict",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.Dict",
|
||||
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Generic": {
|
||||
"name": "Generic",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.Generic",
|
||||
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
|
||||
"docstring": null
|
||||
},
|
||||
"List": {
|
||||
"name": "List",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.List",
|
||||
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Optional": {
|
||||
"name": "Optional",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.Optional",
|
||||
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
|
||||
"docstring": null
|
||||
},
|
||||
"TypeVar": {
|
||||
"name": "TypeVar",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.TypeVar",
|
||||
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Union": {
|
||||
"name": "Union",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.Union",
|
||||
"signature": "<bound method Alias.signature of Alias('Union', 'typing.Union')>",
|
||||
"docstring": null
|
||||
},
|
||||
"ObjectId": {
|
||||
"name": "ObjectId",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.ObjectId",
|
||||
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
|
||||
"docstring": null
|
||||
},
|
||||
"AsyncIOMotorCollection": {
|
||||
"name": "AsyncIOMotorCollection",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.repository.AsyncIOMotorCollection",
|
||||
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorCollection', 'motor.motor_asyncio.AsyncIOMotorCollection')>",
|
||||
"docstring": null
|
||||
},
|
||||
"MongoConnectionManager": {
|
||||
"name": "MongoConnectionManager",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.MongoConnectionManager",
|
||||
"signature": "<bound method Alias.signature of Alias('MongoConnectionManager', 'mongo_ops.connection.MongoConnectionManager')>",
|
||||
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and \ndatabase instances, ensuring they are properly initialized and closed \nacross the application lifecycle.",
|
||||
"signature": null,
|
||||
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and\ndatabase instances, ensuring they are properly initialized and closed\nacross the application lifecycle.",
|
||||
"members": {
|
||||
"connect": {
|
||||
"name": "connect",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.MongoConnectionManager.connect",
|
||||
"signature": "<bound method Alias.signature of Alias('connect', 'mongo_ops.connection.MongoConnectionManager.connect')>",
|
||||
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri: MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name: Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
|
||||
"signature": "connect(uri: str, db_name: str, **kwargs: Any)",
|
||||
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri (str): MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name (str): Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
|
||||
},
|
||||
"disconnect": {
|
||||
"name": "disconnect",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.MongoConnectionManager.disconnect",
|
||||
"signature": "<bound method Alias.signature of Alias('disconnect', 'mongo_ops.connection.MongoConnectionManager.disconnect')>",
|
||||
"signature": "disconnect()",
|
||||
"docstring": "Close the active MongoDB connection and cleanup resources."
|
||||
},
|
||||
"get_database": {
|
||||
"name": "get_database",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.MongoConnectionManager.get_database",
|
||||
"signature": "<bound method Alias.signature of Alias('get_database', 'mongo_ops.connection.MongoConnectionManager.get_database')>",
|
||||
"signature": "get_database()",
|
||||
"docstring": "Retrieve the current database instance.\n\nReturns:\n AsyncIOMotorDatabase: The active database instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
|
||||
},
|
||||
"get_client": {
|
||||
"name": "get_client",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.MongoConnectionManager.get_client",
|
||||
"signature": "<bound method Alias.signature of Alias('get_client', 'mongo_ops.connection.MongoConnectionManager.get_client')>",
|
||||
"signature": "get_client()",
|
||||
"docstring": "Retrieve the current client instance.\n\nReturns:\n AsyncIOMotorClient: The active Motor client instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
|
||||
},
|
||||
"lifespan": {
|
||||
"name": "lifespan",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.MongoConnectionManager.lifespan",
|
||||
"signature": "<bound method Alias.signature of Alias('lifespan', 'mongo_ops.connection.MongoConnectionManager.lifespan')>",
|
||||
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting \nlifespan management.\n\nArgs:\n uri: MongoDB connection URI.\n db_name: Name of the database.\n **kwargs: Additional Motor client options.\n\nYields:\n AsyncIOMotorDatabase: The active database instance.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
|
||||
"signature": "lifespan(uri: str, db_name: str, **kwargs: Any)",
|
||||
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting\nlifespan management.\n\nNotes:\n Connects to MongoDB on entry, yields the active database instance\n to the context body, and disconnects on exit.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -122,63 +52,63 @@
|
||||
"name": "BaseDocument",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.BaseDocument",
|
||||
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
|
||||
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
|
||||
"signature": null,
|
||||
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
|
||||
"members": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.id",
|
||||
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.created_at",
|
||||
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.updated_at",
|
||||
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"Config": {
|
||||
"name": "Config",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.BaseDocument.Config",
|
||||
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
|
||||
"signature": null,
|
||||
"docstring": null,
|
||||
"members": {
|
||||
"populate_by_name": {
|
||||
"name": "populate_by_name",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.Config.populate_by_name",
|
||||
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"arbitrary_types_allowed": {
|
||||
"name": "arbitrary_types_allowed",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.Config.arbitrary_types_allowed",
|
||||
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"json_encoders": {
|
||||
"name": "json_encoders",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.Config.json_encoders",
|
||||
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"json_schema_extra": {
|
||||
"name": "json_schema_extra",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.BaseDocument.Config.json_schema_extra",
|
||||
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
@@ -189,29 +119,29 @@
|
||||
"name": "PopulationEngine",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.PopulationEngine",
|
||||
"signature": "<bound method Alias.signature of Alias('PopulationEngine', 'mongo_ops.populate.engine.PopulationEngine')>",
|
||||
"docstring": null,
|
||||
"signature": "PopulationEngine(repos: dict[str, Any], global_max_depth: int = 10)",
|
||||
"docstring": "Resolves FK references across collections with cycle detection.\n\nThe engine holds a registry of repositories keyed by collection name and\nwalks documents according to PopulateRules, resolving ObjectId references\ninto model instances. A visited-path set guards against circular graphs.\n\nNotes:\n **Guarantees:**\n\n - A reference that cannot be resolved becomes None (scalar) or a\n None entry (list) rather than raising.\n - Depth is capped by both per-rule max_depth and a global\n global_max_depth.",
|
||||
"members": {
|
||||
"register_repo": {
|
||||
"name": "register_repo",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulationEngine.register_repo",
|
||||
"signature": "<bound method Alias.signature of Alias('register_repo', 'mongo_ops.populate.engine.PopulationEngine.register_repo')>",
|
||||
"docstring": null
|
||||
"signature": "register_repo(collection_name: str, repo: Any)",
|
||||
"docstring": "Register or replace the repository for a collection.\n\nArgs:\n collection_name (str):\n Collection the repository manages.\n repo (Any):\n Repository exposing get_by_id() used to resolve references."
|
||||
},
|
||||
"populate": {
|
||||
"name": "populate",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulationEngine.populate",
|
||||
"signature": "<bound method Alias.signature of Alias('populate', 'mongo_ops.populate.engine.PopulationEngine.populate')>",
|
||||
"docstring": null
|
||||
"signature": "populate(document: T, rules: list[PopulateRule], depth: int = 0, _visited: set[tuple[str, str]] | None = None, _path: list[str] | None = None)",
|
||||
"docstring": "Resolve FK fields on a document according to the given rules.\n\nArgs:\n document (T):\n The document to populate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to resolve and how deep.\n depth (int):\n Current recursion depth. Defaults to 0.\n _visited (Optional[set[tuple[str, str]]]):\n Internal set of (class, id) pairs on the active path.\n _path (Optional[list[str]]):\n Internal path labels used for cycle reporting.\n\nReturns:\n T: The populated document.\n\nRaises:\n CircularReferenceError: If a cycle is detected on the active path."
|
||||
},
|
||||
"depopulate": {
|
||||
"name": "depopulate",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulationEngine.depopulate",
|
||||
"signature": "<bound method Alias.signature of Alias('depopulate', 'mongo_ops.populate.engine.PopulationEngine.depopulate')>",
|
||||
"docstring": null
|
||||
"signature": "depopulate(document: T, rules: list[PopulateRule])",
|
||||
"docstring": "Collapse populated model references back to their ObjectIds.\n\nThis is the inverse of populate(): model-valued FK fields are reduced\nto stored identifiers before the document is written to MongoDB.\n\nArgs:\n document (T):\n The document to depopulate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to collapse.\n\nReturns:\n T: The depopulated document.\n\nRaises:\n AttributeError: If a list entry is not a BaseDocument where\n expected."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -219,49 +149,49 @@
|
||||
"name": "PopulateRule",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.PopulateRule",
|
||||
"signature": "<bound method Alias.signature of Alias('PopulateRule', 'mongo_ops.populate.rules.PopulateRule')>",
|
||||
"docstring": null,
|
||||
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
|
||||
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
|
||||
"members": {
|
||||
"field_name": {
|
||||
"name": "field_name",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.PopulateRule.field_name",
|
||||
"signature": "<bound method Alias.signature of Alias('field_name', 'mongo_ops.populate.rules.PopulateRule.field_name')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"collection_name": {
|
||||
"name": "collection_name",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.PopulateRule.collection_name",
|
||||
"signature": "<bound method Alias.signature of Alias('collection_name', 'mongo_ops.populate.rules.PopulateRule.collection_name')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"nested_rules": {
|
||||
"name": "nested_rules",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.PopulateRule.nested_rules",
|
||||
"signature": "<bound method Alias.signature of Alias('nested_rules', 'mongo_ops.populate.rules.PopulateRule.nested_rules')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"max_depth": {
|
||||
"name": "max_depth",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.PopulateRule.max_depth",
|
||||
"signature": "<bound method Alias.signature of Alias('max_depth', 'mongo_ops.populate.rules.PopulateRule.max_depth')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"filter": {
|
||||
"name": "filter",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.PopulateRule.filter",
|
||||
"signature": "<bound method Alias.signature of Alias('filter', 'mongo_ops.populate.rules.PopulateRule.filter')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"projection": {
|
||||
"name": "projection",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.repository.PopulateRule.projection",
|
||||
"signature": "<bound method Alias.signature of Alias('projection', 'mongo_ops.populate.rules.PopulateRule.projection')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
@@ -277,8 +207,8 @@
|
||||
"name": "CRUDMixin",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.CRUDMixin",
|
||||
"signature": "<bound method Class.signature of Class('CRUDMixin', 16, 196)>",
|
||||
"docstring": "Generic CRUD operations mixin for MongoDB collections.\n\nThis mixin provides standard Create, Read, Update, and Delete operations \nthat work with Pydantic models.\n\nAttributes:\n collection: The Motor collection instance.\n model: The Pydantic model class representing the document.",
|
||||
"signature": "CRUDMixin(collection: AsyncIOMotorCollection, model: type[T])",
|
||||
"docstring": "Generic CRUD operations mixin for MongoDB collections.\n\nThis mixin provides standard Create, Read, Update, and Delete operations\nthat work with Pydantic models.\n\nAttributes:\n collection: The Motor collection instance.\n model: The Pydantic model class representing the document.",
|
||||
"members": {
|
||||
"collection": {
|
||||
"name": "collection",
|
||||
@@ -298,57 +228,57 @@
|
||||
"name": "data_to_model",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.data_to_model",
|
||||
"signature": "<bound method Function.signature of Function('data_to_model', 39, 40)>",
|
||||
"signature": "data_to_model(data: dict) -> T",
|
||||
"docstring": null
|
||||
},
|
||||
"create": {
|
||||
"name": "create",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.create",
|
||||
"signature": "<bound method Function.signature of Function('create', 42, 58)>",
|
||||
"docstring": "Create a new document in the collection.\n\nArgs:\n data: The Pydantic model instance to insert.\n\nReturns:\n T: The created Pydantic model instance, including the assigned ID."
|
||||
"signature": "create(data: T) -> T",
|
||||
"docstring": "Create a new document in the collection.\n\nArgs:\n data (T): The Pydantic model instance to insert.\n\nReturns:\n T: The created Pydantic model instance, including the assigned ID."
|
||||
},
|
||||
"get_by_id": {
|
||||
"name": "get_by_id",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.get_by_id",
|
||||
"signature": "<bound method Function.signature of Function('get_by_id', 60, 74)>",
|
||||
"docstring": "Retrieve a document by its ID.\n\nArgs:\n id: The document ID (string or ObjectId).\n\nReturns:\n Optional[T]: The Pydantic model instance if found, else None."
|
||||
"signature": "get_by_id(id: str | ObjectId) -> T | None",
|
||||
"docstring": "Retrieve a document by its ID.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n\nReturns:\n Optional[T]: The Pydantic model instance if found, else None."
|
||||
},
|
||||
"get_many": {
|
||||
"name": "get_many",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.get_many",
|
||||
"signature": "<bound method Function.signature of Function('get_many', 76, 115)>",
|
||||
"docstring": "Retrieve multiple documents with filtering, pagination, and sorting.\n\nArgs:\n filter: MongoDB filter dictionary (e.g., {\"is_active\": True}).\n skip: Number of documents to skip for pagination.\n limit: Maximum number of documents to return (default 100).\n sort: List of sort specifications [(field, direction), ...].\n E.g., [(\"created_at\", -1)] for descending.\n\nReturns:\n List[T]: A list of Pydantic model instances.\n\nUsage:\n ```python\n users = await repo.get_many(\n filter={\"role\": \"admin\"},\n limit=10,\n sort=[(\"username\", 1)]\n )\n ```"
|
||||
"signature": "get_many(filter: dict[str, Any] | None = None, skip: int = 0, limit: int = 100, sort: list[tuple] | None = None) -> list[T]",
|
||||
"docstring": "Retrieve multiple documents with filtering, pagination, and sorting.\n\nArgs:\n filter (Optional[Dict[str, Any]]): MongoDB filter dictionary (e.g., {\"is_active\": True}).\n skip (int): Number of documents to skip for pagination.\n limit (int): Maximum number of documents to return (default 100).\n sort (Optional[List[tuple]]): List of sort specifications [(field, direction), ...].\n E.g., [(\"created_at\", -1)] for descending.\n\nReturns:\n List[T]: A list of Pydantic model instances.\n\nExample:\n ```python\n users = await repo.get_many(\n filter={\"role\": \"admin\"},\n limit=10,\n sort=[(\"username\", 1)]\n )\n ```"
|
||||
},
|
||||
"update": {
|
||||
"name": "update",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.update",
|
||||
"signature": "<bound method Function.signature of Function('update', 117, 142)>",
|
||||
"docstring": "Update a document by its ID using the $set operator.\n\nArgs:\n id: The document ID (string or ObjectId).\n data: A dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None.\n\nUsage:\n ```python\n updated_user = await repo.update(user_id, {\"email\": \"new@example.com\"})\n ```"
|
||||
"signature": "update(id: str | ObjectId, data: dict[str, Any]) -> T | None",
|
||||
"docstring": "Update a document by its ID using the $set operator.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n data (Dict[str, Any]): A dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None.\n\nExample:\n ```python\n updated_user = await repo.update(user_id, {\"email\": \"new@example.com\"})\n ```"
|
||||
},
|
||||
"patch": {
|
||||
"name": "patch",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.patch",
|
||||
"signature": "<bound method Function.signature of Function('patch', 144, 167)>",
|
||||
"docstring": "Partially update a document using $set (REST PATCH semantics).\n\nUnlike update(), patch() takes a partial dict and applies only those\nfields. PopulatingRepository overrides this to prevent patching FK fields.\n\nArgs:\n id: The document ID (string or ObjectId).\n data: A partial dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None."
|
||||
"signature": "patch(id: str | ObjectId, data: dict[str, Any]) -> T | None",
|
||||
"docstring": "Partially update a document using $set (REST PATCH semantics).\n\nUnlike update(), patch() takes a partial dict and applies only those\nfields. PopulatingRepository overrides this to prevent patching FK fields.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n data (Dict[str, Any]): A partial dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None."
|
||||
},
|
||||
"delete": {
|
||||
"name": "delete",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.delete",
|
||||
"signature": "<bound method Function.signature of Function('delete', 169, 183)>",
|
||||
"docstring": "Delete a document by its ID.\n\nArgs:\n id: The document ID (string or ObjectId).\n\nReturns:\n bool: True if a document was deleted, False otherwise."
|
||||
"signature": "delete(id: str | ObjectId) -> bool",
|
||||
"docstring": "Delete a document by its ID.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n\nReturns:\n bool: True if a document was deleted, False otherwise."
|
||||
},
|
||||
"count": {
|
||||
"name": "count",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.CRUDMixin.count",
|
||||
"signature": "<bound method Function.signature of Function('count', 185, 196)>",
|
||||
"docstring": "Count documents matching a filter.\n\nArgs:\n filter: MongoDB filter dictionary.\n\nReturns:\n int: The number of matching documents."
|
||||
"signature": "count(filter: dict[str, Any] | None = None) -> int",
|
||||
"docstring": "Count documents matching a filter.\n\nArgs:\n filter (Optional[Dict[str, Any]]): MongoDB filter dictionary.\n\nReturns:\n int: The number of matching documents."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -356,8 +286,8 @@
|
||||
"name": "BaseRepository",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.BaseRepository",
|
||||
"signature": "<bound method Class.signature of Class('BaseRepository', 199, 221)>",
|
||||
"docstring": "Base repository class combining CRUD operations and collection management.\n\nThis class simplifies repository creation by automatically obtaining the \ndatabase connection and collection instance.\n\nAttributes:\n collection_name: The name of the collection managed by this repository.",
|
||||
"signature": "BaseRepository(collection_name: str, model: type[T])",
|
||||
"docstring": "Base repository class combining CRUD operations and collection management.\n\nThis class simplifies repository creation by automatically obtaining the\ndatabase connection and collection instance.\n\nAttributes:\n collection_name: The name of the collection managed by this repository.",
|
||||
"members": {
|
||||
"collection_name": {
|
||||
"name": "collection_name",
|
||||
@@ -372,8 +302,8 @@
|
||||
"name": "PopulatingRepository",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.repository.PopulatingRepository",
|
||||
"signature": "<bound method Class.signature of Class('PopulatingRepository', 224, 342)>",
|
||||
"docstring": null,
|
||||
"signature": "PopulatingRepository(collection_name: str, model: type[T], population_engine: PopulationEngine | None = None, populate_rules: list[PopulateRule] | None = None)",
|
||||
"docstring": "Repository that auto-populates and depopulates FK references.\n\nOn read, ObjectId FK fields are resolved to model instances according to\nthe configured PopulateRules. On write, populated model references are\ncollapsed back to ObjectIds before hitting MongoDB.\n\nNotes:\n **Guarantees:**\n\n - Populate rules apply on both read (data_to_model) and write\n (create/update) paths.\n - Patching FK fields via patch() is rejected.\n - Class attributes `population_engine` and `_populate_rules` must\n be set (see set_population_engine/set_populate_rules) for any\n population to occur.",
|
||||
"members": {
|
||||
"population_engine": {
|
||||
"name": "population_engine",
|
||||
@@ -386,43 +316,43 @@
|
||||
"name": "set_population_engine",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulatingRepository.set_population_engine",
|
||||
"signature": "<bound method Function.signature of Function('set_population_engine', 236, 237)>",
|
||||
"docstring": null
|
||||
"signature": "set_population_engine(engine: PopulationEngine) -> None",
|
||||
"docstring": "Attach (or replace) the population engine.\n\nArgs:\n engine (PopulationEngine):\n Engine used to resolve references."
|
||||
},
|
||||
"set_populate_rules": {
|
||||
"name": "set_populate_rules",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulatingRepository.set_populate_rules",
|
||||
"signature": "<bound method Function.signature of Function('set_populate_rules', 239, 240)>",
|
||||
"docstring": null
|
||||
"signature": "set_populate_rules(rules: list[PopulateRule]) -> None",
|
||||
"docstring": "Set the FK resolution rules.\n\nArgs:\n rules (list[PopulateRule]):\n Rules describing which fields resolve and how deep."
|
||||
},
|
||||
"data_to_model": {
|
||||
"name": "data_to_model",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulatingRepository.data_to_model",
|
||||
"signature": "<bound method Function.signature of Function('data_to_model', 242, 244)>",
|
||||
"docstring": null
|
||||
"signature": "data_to_model(data: dict) -> T",
|
||||
"docstring": "Convert a raw dict to a model, resolving FK references first.\n\nArgs:\n data (dict):\n Raw document dictionary.\n\nReturns:\n T: The populated model instance.\n\nRaises:\n ValueError: If a FK field holds an embedded dict instead of an\n ObjectId."
|
||||
},
|
||||
"create": {
|
||||
"name": "create",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulatingRepository.create",
|
||||
"signature": "<bound method Function.signature of Function('create', 322, 328)>",
|
||||
"docstring": null
|
||||
"signature": "create(data: T) -> T",
|
||||
"docstring": "Depopulate, insert, and re-populate a new document.\n\nArgs:\n data (T):\n The model instance to insert (FK fields may hold models).\n\nReturns:\n T: The created model instance, including its ID."
|
||||
},
|
||||
"update": {
|
||||
"name": "update",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulatingRepository.update",
|
||||
"signature": "<bound method Function.signature of Function('update', 330, 332)>",
|
||||
"docstring": null
|
||||
"signature": "update(id: str | ObjectId, data: T) -> T | None",
|
||||
"docstring": "Depopulate and update a document by ID.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n data (T):\n The model instance holding the updated fields.\n\nReturns:\n Optional[T]: The updated model instance, or None when not found."
|
||||
},
|
||||
"patch": {
|
||||
"name": "patch",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.repository.PopulatingRepository.patch",
|
||||
"signature": "<bound method Function.signature of Function('patch', 334, 342)>",
|
||||
"docstring": null
|
||||
"signature": "patch(id: str | ObjectId, data: dict[str, Any]) -> T | None",
|
||||
"docstring": "Partially update a document, rejecting FK field changes.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n data (dict[str, Any]):\n Partial dictionary of fields to update.\n\nReturns:\n Optional[T]: The updated model instance, or None when not found.\n\nRaises:\n ValueError: If any FK field is present in the patch payload."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user