Yet another object-relational mapping plugin for Egg, which is based on Leoric.
Install
$ npm i --save egg-orm
$ npm install --save mysql # MySQL or compatible dialects
# Or use other database backend.
$ npm install --save pg # PostgreSQL
$ npm install --save sqlite3 # SQLite
Usage
With egg-orm you can define models in app/model in JavaScript:
In this example above, we’re accessing the temp database of MySQL via localhost with the models defined in directory app/model. For more information, please refer to Setup Leoric in Egg.
egg-orm
中文介绍
Yet another object-relational mapping plugin for Egg, which is based on Leoric.
Install
Usage
With egg-orm you can define models in
app/modelin JavaScript:or in TypeScript:
and use them like below:
Configuration
Firstly, enable egg-orm plugin:
Secondly, configure the plugin accordingly:
In this example above, we’re accessing the
tempdatabase of MySQL vialocalhostwith the models defined in directoryapp/model. For more information, please refer to Setup Leoric in Egg.License
MIT