the name of the field
The definition of the field
Readonly
nameAdd a new action on the collection.
.addAction('is live', {
scope: 'Single',
execute: async (context, resultBuilder) => {
return resultBuilder.success('Is live!');
},
})
the name of the action
the definition of the action
Create a new API chart
.addChart('numCustomers', (context, resultBuilder) => {
return resultBuilder.distribution({
tomatoes: 10,
potatoes: 20,
carrots: 30,
});
})
name of the chart
definition of the chart
Add a virtual collection into the related data of a record.
.addExternalRelation('states', {
schema: { code: 'Number', name: 'String' },
listRecords: ({ id }) => {
return record.id == 34 ?
[{ code: 'AL', name: 'Alabama' }, { code: 'AK', name: 'Alaska' }] :
[{ code: 'AZ', name: 'Arizona' }, { code: 'TX', name: 'Texas' }];
}
})
name of the relation
the definition of the new relation
Add a new validator to the edition form of a given field
.addFieldValidation('firstName', 'LongerThan', 2);
The name of the field
The validator that you wish to add
Optional
value: unknownA configuration value that the validator may need
Add a new hook handler to an action
.addHook('Before', 'List', async (context) => {
// Do something before the list action
});
Either if the hook is executed before or after the action
Type of action which should be hooked
Callback that should be executed when the hook is triggered
Add a many to many relation to the collection
dvds.addManyToManyRelation('rentalsOfThisDvd', 'rentals', 'dvdRentals', {
originKey: 'dvdId',
foreignKey: 'rentalId'
})
name of the new relation
name of the targeted collection
name of the intermediary collection
extra information about the relation
Optional
foreignOptional
originAdd a many to one relation to the collection
books.addManyToOneRelation('myAuthor', 'persons', { foreignKey: 'authorId' })
name of the new relation
name of the targeted collection
extra information about the relation
Optional
foreignAdd a one to many relation to the collection
persons.addOneToManyRelation('writtenBooks', 'books', { originKey: 'authorId' })
name of the new relation
name of the targeted collection
extra information about the relation
Optional
originAdd a one to one relation to the collection
persons.addOneToOneRelation('bestFriend', 'persons', { originKey: 'bestFriendId' })
name of the new relation
name of the targeted collection
extra information about the relation
Optional
originAdd a new segment on the collection.
.addSegment(
'Wrote more than 2 books',
{ field: 'booksCount', operator: 'GreaterThan', value: 2 }
);
the name of the segment
a function used to generate a condition tree or a condition tree
Disable count in list view pagination for improved performance.
.disableCount()
the name of the field with sorting to be disabled
Enable filtering on a specific field using emulation. As for all the emulation method, the field filtering will be done in-memory.
.emulateFieldFiltering('aField');
the name of the field to enable emulation on
Enable filtering on a specific field with a specific operator using emulation. As for all the emulation method, the field filtering will be done in-memory.
.emulateFieldOperator('aField', 'In');
the name of the field to enable emulation on
the operator to emulate
Enable sorting on a specific field using emulation. As for all the emulation method, the field sorting will be done in-memory.
.emulateFieldSorting('fullName');
the name of the field to enable emulation on
Import a field from a many to one or one to one relation.
.importField('authorName', { path: 'author:fullName' })
the name of the field that will be created on the collection
options to import the field
Optional
readonly?: booleanReplace the default create operation
.overrideCreate(async (context) => {
const { data } = context;
const record = await createRecord(data);
return [record];
});
the new behavior for the create operation
Replace the default delete operation
.overrideDelete(async (context) => {
const { filter } = context;
await deleteRecord(filter);
});
the new behavior for the delete operation
Replace the default update operation
.overrideUpdate(async (context) => {
const { filter, patch } = context;
await updateRecord(filter, patch);
});
the new behavior for the update operation
Remove fields from the exported schema (they will still be usable within the agent).
.removeField('fieldNameToRemove', 'relationNameToRemove');
Rest
...names: TColumnNameAndRelationName<S, N>[]the names of the field or the relation
Rename fields from the exported schema.
.renameField('currentFieldOrRelationName', 'newFieldOrRelationName')
the current name of the field or the relation in a given collection
the new name of the field or the relation
Choose how binary data should be transported to the GUI. By default, all fields are transported as 'datauri', with the exception of primary and foreign keys.
Using 'datauri' allows to use the FilePicker widget, while 'hex' is more suitable for short binary data (for instance binary uuids).
.replaceFieldBinaryMode('avatar', 'datauri');
the name of the field
either 'datauri' or 'hex'
Replace an implementation for a specific operator on a specific field. The operator replacement will be done by the datasource.
.replaceFieldOperator('fullName', 'Contains', (value) => {
return {
aggregator: 'Or',
conditions: [{
field: 'firstName',
operator: 'Contains',
value
}, {
field: 'lastName',
operator: 'Contains',
value
}]
}
});
the name of the field to filter on
the operator to replace
the proposed implementation
Replace an implementation for the sorting. The field sorting will be done by the datasource.
.replaceFieldSorting(
'fullName',
[
{ field: 'firstName', ascending: true },
{ field: 'lastName', ascending: true },
]
)
the name of the field to enable sort
the sort equivalent
Replace the write behavior of a field.
.replaceFieldWriting('fullName', fullName => {
const [firstName, lastName] = fullName.split(' ');
return { firstName, lastName };
});
the name of the field
the function or a value to represent the write behavior
Replace the behavior of the search bar
.replaceSearch(async (searchString) => {
return { field: 'name', operator: 'Contains', value: searchString };
});
handler to describe the new behavior
Load a plugin on the collection.
import { createFileField } from '@forestadmin/plugin-s3';
collection.use(createFileField, { fieldname: 'avatar' }),
reference to the plugin function
Optional
options: Optionsoptions to pass to the plugin
Add a new field on the collection.
See
Documentation Link
Example