That single mount registers 14+ endpoints. You can also reach every operation programmatically via
booksEntity.service.
typescript interface extension
Extend BaseEntityDocument and pass it as the generic to get fully typed service methods and
event callbacks.
typescript
interface BookDocument extends BaseEntityDocument {
isbn: string
pageCount: number
libraryId: string
}
const booksEntity = newMetaEntity<BookDocument>("books", { ... })
// service is IMetaService<BookDocument>const book = await booksEntity.service.findById(id)
// book is BookDocument | null
entity options reference
option
type
default
description
entity
MetaEntity is the single constructor. It validates the MongoDB connection, compiles the
Mongoose schema, creates the service and controller, and exposes the event emitter.
Connection guard. MetaEntity throws immediately if
mongoose.connection.readyState is 0 (disconnected). Always call mongoose.connect() before constructing
entity instances.
The service layer exposes every data operation as an async method. Accessing
entity.service gives you the same logic that powers the HTTP controller, usable directly in
your business code.
endpoints
events
event types
callback nullability
examples
interceptors
action types
notes
field resolution per route
When a field-targeted interceptor pattern like update.provider_id is registered, the field name is extracted from the request differently depending on which route is hit.
examples
nested operations
operators
usage examples
typescript
// set a nested object propertyawait profileEntity.nested(id, {
field: "personal_information.email",
operation: "set",
value: "new@email.com"
})
// update a specific services[] item by _mmidawait profileEntity.nested(id, {
field: "services",
operation: "patch_item",
value: { _mmid: "mmid-cleaning", category: "Premium Cleaning" }
})
// remove a service by _mmidawait profileEntity.nested(id, {
field: "services",
operation: "pull_id",
value: "mmid-laundry"
})
// batch - applied in minimum round-tripsawait profileEntity.nestedBatch(id, [
{ field: "rating_average", operation: "increment", value: 0.5 },
{ field: "tags", operation: "push", value: "verified" },
{ field: "personal_information.phone", operation: "set", value: "08012345678" }
])
relations
validation
schema setup
typescript
options
option
description
createSchema
Joi schema map for create. Required constraints are enforced.
updateSchema
Joi schema map for update. Defaults to createSchema with all keys optional.
createValidationOptions
Any Joi.ValidationOptions. Default: { abortEarly: false, allowUnknown: true }.
updateValidationOptions
Same as above, for update calls.
skipValidation
Pass { skipValidation: true } to service.create() or service.update() to bypass Joi entirely.
TypeScript
Document extension
typescript
key types exported
type
description
MetaEntity<T>
The main entity class.
IMetaService<T>
Service interface. All methods typed against T.
BaseEntityDocument
Base document shape with all injected fields.
EventPath<T>
Union of all valid event strings inferred from T's shape.
CallbackForEvent<T, E>
Resolves correct callback nullability from the event string E.
UpdateEventCallback<T>
Both whatWas and whatIs are non-null Partial<T>.
CreateEventCallback<T>
whatWas and whatIs are null. Entity is T.
DeleteEventCallback<T>
whatWas is non-null Partial<T>. whatIs is null.
NestedOpPayload
{ field, operation, value } for nested operations.