egg-fortypeorm
v1.0.5
Published
a plugin for egg to solve the orm
Downloads
2
Maintainers
Readme
egg-fortypeorm
Install
$ npm i egg-fortypeorm --save
Usage
// {app_root}/config/plugin.js
exports.typeorm = {
enable: true,
package: 'egg-fortypeorm',
};
Configuration
// {app_root}/config/config.default.js example:
exports.typeorm = {
type: "mysql",
host: "127.0.0.1",
port: 3306,
username: "root",
password: "xxx",
database: "test",
synchronize: true,
entities:[Photo]
};
see config/config.default.js for more detail.
Example
export default class HomeController extends Controller {
public async index() {
const { ctx } = this;
const photo = new Photo();
photo.name = 'P1';
photo.fileName = 'p1.png';
photo.isPublished = true;
photo.views = 0;
ctx.body = await ctx.connection.manager.save(photo);
}
}
Questions & Suggestions
Please open an issue here.