Classes
Methods
# abstract static isAdapterFor(rawResource) → {Boolean}
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
# build(params) → {BaseRecord}
Each Record is an representation of the resource item. Before it can be saved, it has to be instantiated.
This function has to be implemented if you want to create new records.
Parameters:
Name | Type | Description |
---|---|---|
params |
Record.<string, any>
|
# async abstract count(filter) → {Promise.<Number>}
Parameters:
Name | Type | Description |
---|---|---|
filter |
Filter
|
represents what data should be included |
Promise.<Number>
# async abstract create(params) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
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>
# abstract databaseName() → {String}
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
# databaseType() → {String}
given resource. Default: 'database'
String
# async abstract delete(id) → {Promise.<void>}
Parameters:
Name | Type | Description |
---|---|---|
id |
String
|
Number
|
id of the Record |
If there are validation errors it should be thrown
Promise.<void>
# async abstract find(filters, options) → {Promise.<Array.<BaseRecord>>}
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 findMany(list) → {Promise.<Array.<BaseRecord>>}
Parameters:
Name | Type | Description |
---|---|---|
list |
Array.<string>
|
of ids to find |
records
Promise.<Array.<BaseRecord>>
# async abstract findOne(id) → {Promise.<BaseRecord>|null}
Parameters:
Name | Type | Description |
---|---|---|
id |
String
|
uniq id of the Resource Record |
record
Promise.<BaseRecord>
|
null
# abstract id() → {String}
For instance in Router path for the new
form is /resources/{resourceId}/new
uniq resource id
String
# abstract properties() → {Array.<BaseProperty>}
Array.<BaseProperty>
# abstract property(path) → {BaseProperty|null}
Parameters:
Name | Type | Description |
---|---|---|
path |
String
|
path/name of the property. Take a look at BaseProperty to learn more about property paths. |
BaseProperty
|
null
# async abstract update(id, params) → {Promise.<Object>}
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>