Classes
Methods
# abstract static isAdapterFor(rawResource) → {Boolean}
Checks if given adapter supports resource provided by the user.
This function has to be implemented only if you want to create your custom database adapter.
For one time Admin Resource creation - it is not needed.
Parameters:
| Name | Type | Description |
|---|---|---|
rawResource |
any
|
resource provided in AdminJSOptions#resources array |
if given adapter supports this resource - returns true
Boolean
# abstract databaseName() → {String}
The name of the database to which resource belongs. When resource is
a mongoose model it should be database name of the mongo database.
Visually, by default, all resources are nested in sidebar under their database names.
database name
String
# async abstract find(filters, options) → {Promise.<Array.<BaseRecord>>}
Returns actual records for given resource
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
filters |
Filter
|
what data should be included |
|
options |
Object
|
||
limit |
Number
|
<optional> |
how many records should be taken |
offset |
Number
|
<optional> |
offset |
sort |
Object
|
<optional> |
sort |
sort.sortBy |
Number
|
<optional> |
sortable field |
sort.direction |
Number
|
<optional> |
either asc or desc |
list of records
Promise.<Array.<BaseRecord>>
Example
// filters example
{
name: 'Tom',
createdAt: { from: '2019-01-01', to: '2019-01-18' }
}
# async abstract update(id, params) → {Promise.<Object>}
Updates an the record.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String
|
uniq id of the Resource Record |
params |
Record.<string, any>
|
If there are validation errors it should be thrown
created record converted to raw Object which can be used to initiate new BaseRecord instance
Promise.<Object>