Event management system for database collection operations.
This class provides event handling capabilities for database operations,
allowing you to register listeners that are called when documents are
inserted, updated, or deleted from a collection.
Each event type supports both synchronous and asynchronous listeners,
making it flexible for various use cases such as:
An abstract class representing a MongoDB collection with utility methods.
The DBCollectionFree class provides an abstraction over a MongoDB collection,
offering various methods to interact with the database, such as checking for
the existence of a document by its ID, updating fields, form validation,
and generating REST API routes. This class is meant to be extended by other
classes for more specific collection implementations.
Features include:
Configuration class for MongoDB database indexes.
This class encapsulates all the configuration options needed to create
a MongoDB index. It provides a convenient way to define index properties
that will be used when creating indexes on collection fields.
MongoDB indexes improve query performance and can enforce constraints
like uniqueness. This class supports all major index options including:
Generic event system for handling typed events with multiple listeners.
This class provides a flexible event system that supports both synchronous
and asynchronous listeners. Events can be emitted with typed data, and all
registered listeners will be called in the order they were added.
Features:
A class that provides a map with a default value for missing keys.
This class wraps a standard Map and provides an operator to access map values. If a key is not
found in the map, it returns a default value. If the default value is a String, it can include
a placeholder @key that will be replaced with the missing key.
Example usage:
A class that wraps around ModelLess and provides additional functionality or abstraction.
This class is designed to manage and interact with an instance of ModelLess.
It initializes with a ModelLess object or creates a default instance from an empty JSON string if none is provided.
The ModelLess class is a dynamic, flexible data structure designed to handle
nested data structures and perform common operations such as accessing,
setting, and manipulating data within the structure. This class is
particularly useful in scenarios where you need to work with JSON-like data
structures that may contain nested maps or lists. Below is a detailed
breakdown of the key features and methods in the ModelLess class.
The ModelLessArray class is a generic class that provides a structure for
managing a collection of items, specifically designed to work with ModelLess
objects. This class offers features such as accessing items by index,
dynamically setting and getting values, parsing JSON into the array, and
retrieving nested data using paths. Below is an explanation and breakdown
of the key features:
Utility class for parsing and processing MongoDB error responses.
This class provides static methods to analyze MongoDB operation errors
and convert them into a more accessible format. It's particularly useful
for handling write errors that occur during insert, update, or delete
operations.
The class can extract field-specific errors from MongoDB's error response
format, making it easier to provide meaningful error messages to users
and identify which fields caused validation or constraint violations.
Example:
A set of extension methods for dynamic types to facilitate type conversion
and provide default values when conversion is not possible.
These methods help in safely converting dynamic values to specific types
such as int, double, String, bool, List, ObjectId, and DateTime.
Each method allows specifying a default value to return if the conversion fails.
Example usage:
Extension on Map that provides utility methods for type conversion and data extraction.
This extension adds methods to safely extract and convert values from a map with default values if the key is not found or if the value cannot be converted.
Type definition for asynchronous event listener functions.
These functions can perform async operations and are awaited during
event emission, which means they can delay the completion of the
database operation that triggered the event.
Type definition for synchronous event listener functions.
These functions are called immediately when an event is emitted
and should complete quickly to avoid blocking the event emission process.