Node.js libraries

DataTable's Node.js libraries are designed to make it super easy to create a script on the server-side that will provide an anchor point for any client-side interaction made by DataTables and its extensions.

Features

The DataTables Node.js libraries have the following features:

These libraries are available on npm as datatables.net-editor-server, which you can install using npm or yarn. The Editor example package for Node.js will install those libraries when you run npm install.

This section of the Editor manual goes into detail about how to set up, configure and use the Editor NodeJS libraries.

Reference documentation is also available for Editor's Node.js libraries, which document in detail the API interfaces and options of the classes and methods provided by the assembly.

Node.js libraries manual

Installing

DataTables and Editor are powerful libraries, but before you can use them, they need to be installed on your system! This guide walks through how to install the Node.js server-side libraries. Read more »

Reading data

The DataTable class provides a read only interface to a database table, reading the data from the columns configured and returning it to the client-side for display in response to a DataTables ajax request. It also supports server-side processing for large data sets and advanced filtering options. Read more »

Editing

The Editor class is one of the main access points for processing requests from the server-side. It can handle all requests for reading and writing data to a database for a DataTable. The class instance will be configured with the fields that it should operate on. Read more »

Formatters

Often the data that is stored in the database is not in a format that is suitable for display or manipulate by the end user. A common example of this is a timestamp - the number of seconds since 1st January 1970 means little to anyone, even experienced developers, but it is a useful format to hold the data in, since it can be sorted and filtered quickly in the database. For this reason the Field class provides get and set formatters - specifically the getFormatter and setFormatter methods. Read more »

Joins

A cornerstone of CRUD applications is the ability to combine information from multiple SQL tables, representing the combined data as a common data set that the end user can easily understand and manipulate. Relational databases are, after all, designed for exactly this sort of data referencing. Often in CRUD applications, working with such joined data can significantly increase the complexity of the application and increase development time, Editor makes working with such join tables extremely easy through its leftJoin() method. Complex joins with full CRUD support can be added in just minutes. Read more »

One-to-many Joins

The leftJoin() method is excellent when joining data which has a 1:1 relationship, however, often your data structure will require a one-to-many relationship. An example of this that is often used in the computing world is access privileges: a single user can have access to n systems (where n >= 0). To provide one-to-many support the DataTables Node.js libraries include an Mjoin class (i.e. many join). Read more »

Options

When building forms, there are many cases where you will want to present the end user with a list of options from which a value can be selected. The Options class is available in the Node.js libraries for Editor to fulfill this need. It is attached to an individual field using Field.options() and will resolve, based on its configuration, to a list of options for the field. Read more »

Where Conditions

When displaying data from a database to an end user you may require the ability to filter the data that the end user sees (for example based on account permissions or some other account access permissions). In SQL you would do this with a WHERE condition - the DataTables Node.js libraries also provide a Editor.where() method to expose this functionality and allow complex conditional expressions. Read more »

Validation

Validation of data is of fundamental importance in CRUD applications. You need to be sure that the data that the client is sending you is what you expect! This is not just for security reasons, protecting your data from misuse and intentional corruption, but also simply from unintentional mistakes in submitting data. Strings limited to a certain length, dates in a particular format and required fields are all common uses of data validation. Read more »

Events

When working with complex data, it can often be useful to perform some additional action when Editor updates the database based on information from the client-side. This can take the form of modifying the Editor or Field instances for the action being taken, deleting files from the file system when rows are removed, or adding log information to a database about an action that a user has taken. To make this possible, the Node.js Editor class provides an event listener / callback option similar to the events that the client-side Javascript will trigger. Read more »

File Upload

The DataTables Node.js libraries provide an Upload class that can be used with the upload and uploadMany field types to provide end users with the ability to upload files to a server. The goal of the Upload class is to make the server-side aspect of file uploading as simple as possible, while retaining the same flexibility that you would expect from the DataTables libraries. Read more »

Demo App

To get you started with the DataTables libraries and Editor on your own server (or development machine), we provide a demo application that includes all of the Editor examples on this site, including their server-side scripts and the SQL for the backing database. Read more »