|
2 | 2 | * @module admin-bro-sequelizejs
|
3 | 3 | *
|
4 | 4 | * @description
|
5 |
| - * A Sequelize database adapter for AdminBro. |
| 5 | + * ### A Sequelize database adapter for AdminBro. |
| 6 | + * |
| 7 | + * #### Installation |
| 8 | + * |
| 9 | + * To install the adapter run |
| 10 | + * |
| 11 | + * ``` |
| 12 | + * yarn add admin-bro-sequelizejs |
| 13 | + * ``` |
| 14 | + * |
| 15 | + * ### Usage |
| 16 | + * |
| 17 | + * In order to use it in your project register the adapter first: |
| 18 | + * |
| 19 | + * ```javascript |
| 20 | + * const AdminBro = require('admin-bro') |
| 21 | + * const AdminBroSequelize = require('admin-bro-sequelizejs') |
| 22 | + * |
| 23 | + * AdminBro.registerAdapter(AdminBroSequelize) |
| 24 | + * ``` |
| 25 | + * |
| 26 | + * ### Passing an entire database |
| 27 | + * |
| 28 | + * Sequelize generates folder in your app called `./models` and there is an `index.js` file. |
| 29 | + * You can require it and pass to {@link AdminBroOptions} like this: |
| 30 | + * |
| 31 | + * ```javascript |
| 32 | + * const db = require('../models'); |
| 33 | + * const AdminBro = new AdminBro({ |
| 34 | + * databases: [db], |
| 35 | + * //... other AdminBroOptions |
| 36 | + * }) |
| 37 | + * //... |
| 38 | + * ``` |
| 39 | + * |
| 40 | + * ### Passing each resource |
| 41 | + * |
| 42 | + * Also you can pass a single resource and adjust it to your needs via {@link ResourceOptions}. |
| 43 | + * |
| 44 | + * So let say you have a model called `vendor` and there is a `vendor.js` file in your `./models`. |
| 45 | + * Within this file there is |
| 46 | + * |
| 47 | + * ```javascript |
| 48 | + * //... |
| 49 | + * sequelize.define('vendor', //... |
| 50 | + * //... |
| 51 | + * ``` |
| 52 | + * |
| 53 | + * In order to pass it directly, run this code: |
| 54 | + * |
| 55 | + * ```javascript |
| 56 | + * const db = require('../models'); |
| 57 | + * const AdminBro = new AdminBro({ |
| 58 | + * databases: [db], // you can still load an entire database and adjust just one resource |
| 59 | + * resources: [{ |
| 60 | + * resource: db.vendor, |
| 61 | + * options: { |
| 62 | + * //... |
| 63 | + * } |
| 64 | + * }] |
| 65 | + * }) |
| 66 | + * //... |
| 67 | + * ``` |
| 68 | + * |
| 69 | + * |
6 | 70 | */
|
7 | 71 |
|
8 | 72 | /**
|
| 73 | + * Implementation of {@link BaseDatabase} for Sequelize Adapter |
| 74 | + * |
9 | 75 | * @type {typeof BaseDatabase}
|
10 | 76 | * @static
|
11 | 77 | */
|
12 | 78 | const Database = require('./src/database')
|
13 | 79 |
|
14 | 80 | /**
|
| 81 | + * Implementation of {@link BaseResource} for Sequelize Adapter |
| 82 | + * |
15 | 83 | * @type {typeof BaseResource}
|
16 | 84 | * @static
|
17 | 85 | */
|
|
0 commit comments