This is a MayaJS library that deals with Mongodb drivers. It uses mongoose to connect to any mongodb database. It also use mongoose Schema and Model for its model creation.
Creates a model intance based on the name passed on the parameter.
MayaJS collect and store all the models defined on the @Controller decorators to a single object. Everytime the @Models decorator is attached to a variable it replace its value with a model instance. This model instance is based on mongoose model. All of mongoose functionality is available for this model instance.
@Models(model_name:string) varaiable_name; @Models("sample") model;A wrapper for mongoose that MayaJS use to connect to MongoDB.
Mongo accepts an object settings that will set the connection for MongoDB. MayaJS will automatically connect to the specified settings whenever the server starts. It will also set the models using the models function. It typically used inside the @App decorator on the options paramater.
{
connectionString: string; // Connection string
options?: ConnectionOptions; // Mongoose connect options OPTIONAL
schemas?: SchemaObject; // Mongoose schema object OPTIONAL
}NOTE: See full documentation of ConnectionOptions here.
@App({
database: Mongo({
connectionString: "your-connection-string-here",
options: {}, // Define Mongodb options
schemas: [], // Add mongoose schema here
}),
})
export class AppModule {}See collaborating guides here.
Author and maintainer Mac Ignacio