@alarife/mongo
v0.1.0
Published
Plugin for mongo databases integrated with the Alarife project.
Downloads
4
Readme
Alarife - Mongo plugin
Alarife mongo plugin is a library that provides a decorator pattern on mongoose.
Decorators
@Mongo
Mongo is a class decorator. This decorator makes the connection to the database.
The decorators are order dependent, first you have to declare @App then the plugins.
import { App, Value } from '@alarife/core/decorators';
import { Mongo } from '@alarife/mongo/decorators';
const configuration = {
uri : 'mongodb+srv://admin:[email protected]/alarife',
options : {
debug : true
}
};
@App()
@Mongo(configuration)
class Main {
constructor() { }
}
@MongoEvent[event]
MongoEvent is a method decorator.
Support for connecting, connected, disconnected, error , disconnecting, reconnected, timeout and close events.
@MongoEvents.connected
onConnected() {
this.log.info('Connected');
}
@MongoEvents.error
onError(err) {
this.log.error('Error', err);
}
LIBRARY IN DEVELOPMENT