0.0.1-beta.0 • Published 5 years ago
curli-mikro-orm-module v0.0.1-beta.0
curli-mikro-orm-module
Mikro ORM implementation for the Curli framework.
Installation
Install by npm
npm install --save curli-mikro-orm-module
Basic Usage
1 - In the configurations file, declare de followings properties:
@DATABASE_NAME: (string) The name of the database.
@DATABASE_DEBUG (boolean) If we want to see de logs.
@DATABASE_TYPE (string) one of mongo
| mysql
| mariadb
| postgresql
| sqlite
@DATABASE_URL (string) like 'mongodb://localhost:27017' for mongodb driver
2 - Add the module definer:
import {MikroOrmModuleDefiner} from "curli-mikro-orm-module";
app.addModulesDefiner(new MikroOrmModuleDefiner(app));
3 - Attach the mapper into the module
public registerDataMappers(dataMappers: HandleDataMappers): void {
dataMappers.addDataMapper(UserMapper);
}
4 - Call the repository (already declared as service)
await this.container.get('userMikroRepository').persist(entity, true);
or
await this.container.get('userMikroRepository').persist(entity);
await this.container.get('mikroEntityManager').flush();
Commands
npm run build
: Build the project (Curli Mikro Orm).npm run build:clean
: Delete first the dist folder and build it.npm run clean
: Delete the dist folder.npm run test
: Execute the tests.npm run test:coverage
: Execute the tests and calculate the coverage.npm run lint
: Check the code using the rules in .eslintre.jsnpm run lint:fix
: Check the code and try to fix it.
License
MIT