Creates an instance of Editor.
Get the data constructed in this instance.
Data object
Get the database connection assigned to the instance.
Knex db interface
Set the database connection.
Self for chaining
Get the id prefix.
Typically primary keys are numeric and this is not a valid ID value in an HTML document - is also increases the likelihood of an ID clash if multiple tables are used on a single page. As such, a prefix is assigned to the primary key value for each row, and this is used as the DOM ID, so Editor can track individual rows.
id prefix
Get the id prefix.
Prefix to use.
Self for chaining
Get the data that is being processed by the Editor instance. This is only
useful once the process()
method has been called, and is available for
use in validation and formatter methods.
Data that has been passed into {@link Editor.process()}
Get the configured Mjoin instances.
Note that for the majority of use cases you will want to use the
leftJoin()
method. It is significantly easier to use if you are just
doing a simple left join!
The list of Join instances that Editor will join the parent table to (i.e. the one that the Editor.table and Editor.fields methods refer to in this class instance).
Array of Mjoin instances
Add one or more Mjoin instances.
Mjoin instance to add.
Self for chaining.
Add a left join condition to the Editor instance, allowing it to operate
over multiple tables. Multiple leftJoin()
calls can be made for a
single Editor instance to join multiple tables.
A left join is the most common type of join that is used with Editor so this method is provided to make its use very easy to configure. Its parameters are basically the same as writing an SQL left join statement, but in this case Editor will handle the create, update and remove requirements of the join for you:
Please note that when using join tables, Editor requires that you fully
qualify each field with the field's table name. SQL can result table
names for ambiguous field names, but for Editor to provide its full CRUD
options, the table name must also be given. For example the field
first_name
in the table users
would be given as users.first_name
.
Table name to do a join onto
Field from the parent table to use as the join link
Join condition (=
, '<`, etc)
Field from the child table to use as the join link
Self for chaining
Add an event listener. The Editor
class will trigger an number of
events that some action can be taken on.
Event name
Event callback function that will be executed when the event occurs.
Self for chaining.
Get the primary key value.
The primary key must be known to Editor so it will know which rows are being edited / deleted upon those actions. The default value is ['id'].
Array of column names
Set the primary key value(s)
Self for chaining.
Convert a primary key combined value to an array of field values.
The id that should be split apart
Array of field values that the id was made up of
Convert a primary key array of field values to a combined value.
The row of data that the primary key value should be extracted from.
The created primary key value.
Process a request from the Editor client-side to get / set data.
Form data sent from the client-side -
e.g. req.body
Promise that is fulfilled when Editor has completed its processing - result is the Editor instance.
Get the table name.
The table name designated which DB table Editor will use as its data
source for working with the database. Table names can be given with an
alias, which can be used to simplify larger table names. The field
names would also need to reflect the alias, just like an SQL query. For
example: users as a
.
Configured table name
Set the table name.
Database table name to use
Self for chaining
Get transaction support status
When enabled (which it is by default) Editor will use an SQL transaction to ensure data integrity while it is performing operations on the table. This can be optionally disabled using this method, if required by your database configuration.
true is transactions are enabled, false otherwise.
Set transaction support state
Set the transaction status
Self for chaining
Get the try/catch status.
Editor uses a try/catch in the Editor.process method, and it can be useful to disable this for debugging, but its not recommended you do that in production.
Try / catch status.
Set the try/catch state.
Value to set. true
will enable, false
disable.
Self for chaining.
Perform validation on a data set.
Note that validation is performed on data only when the action is
create
or edit
. Additionally, validation is performed on the wire
data - i.e. that which is submitted from the client, without formatting.
Any formatting required by setFormatter
is performed after the data
from the client has been validated.
Output array to which field error information will
be written. Each element in the array represents a field in an error
condition. These elements are themselves arrays with two properties
set; name
and status
.
The format data to check
true
if the data is valid, false
if not.
Get any global validator that has been set.
Global validator
Set a global validator. This will be triggered for the create, edit and remove actions performed from the client-side.
Function to execute when validating the input data.
Self for chaining
Get the array of conditions applied to the method.
Knex where conditions.
Set a condition for the queries Editor will perform. Editor uses Knex to connect to the database, and exposes the knex object using this method so you can add any conditions you like that are supported by Knex.
Knex query condition
Self for chaining.
Determine the request type from an HTTP request.
HTTP request - normally request.body
. Note that
if you are using body-parser
you should use { extended: true }
as its
options to ensure that nested properties are correctly resolved.
Indicates what action the request is
Generated using TypeDoc
DataTables Editor base class for creating editable tables.
Editor class instances are capable of servicing all of the requests that DataTables and Editor will make from the client-side - specifically:
The Editor instance is configured with information regarding the database table fields that you which to make editable, and other information needed to read and write to the database (table name for example!).
This documentation is very much focused on describing the API presented by these DataTables Editor classes. For a more general overview of how the Editor class is used, and how to install Editor on your server, please refer to the Editor manual.
Editor
{NestedData}