Scripting Engine

Learn about our server-side JavaScript engine.

Stacklane uses a JavaScript subset for server-side logic. This subset is designed for speed, security, and compile time validation. The primary uses are endpoints and suppliers.

The JS engine implies "use strict" by default, however its strictness goes beyond this standard setting. In general Stacklane will not a let a script successfully compile unless it can validate all properties and methods referenced actually exist. This is particularly helpful when it comes to referencing data models.

Models

Create, read, update, and delete.

Queries

Create criteria based queries to find models.

Suppliers

Reuse values across scripts and templates.

Helpers

Form handling, redirects, and encoding.

Messages

Messages, alerts, and notices across requests.

Email

Send email from scripts.

Differences and Restrictions

The following are common cases where Stacklane server-side JavaScript differs, or places additional restrictions.

Type Description
var Use let
function Use the equivalent compact syntax (..)=>{..}
switch Use if/else
Date Date objects are immutable — any of the Date.setXyz methods are not available.
for, while Free-form iteration is not allowed. In cases that require working on items in bulk, special case callback methods are provided. See query scripting methods, which address many common cases of iteration for data models.
Type Safety Once assigned, variables may not change their type — this works let x = null; x = '1' (null to string), but this does not let x = 1; x = '1' (number to string).