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