pageman / mongo

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mongo Decorators and Modules

Description

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.

Decorators

Models

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.

Pseudo Code

   @Models(model_name:string) varaiable_name;

Sample Code

   @Models("sample") model;

Modules

Mongo

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.

Options

{
  connectionString: string; // Connection string
  options?: ConnectionOptions; // Mongoose connect options OPTIONAL
  schemas?: SchemaObject; // Mongoose schema object OPTIONAL
}

NOTE: See full documentation of ConnectionOptions here.

Sample Code

@App({
  database: Mongo({
    connectionString: "your-connection-string-here",
    options: {}, // Define Mongodb options
    schemas: [], // Add mongoose schema here
  }),
})
export class AppModule {}

Collaborating

See collaborating guides here.

People

Author and maintainer Mac Ignacio

License

MIT

About

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.

License:MIT License


Languages

Language:TypeScript 100.0%