Composer #aggregate #constructor #end #first #groupBy #join #limit #orderBy #safeJoin #safeWhere #update #where SchedulerEntry #constructor #exec #getDateOffset #perform #start #stop Model .calculates .column .columnLookup .columnNames .columns .create .destroy .find .hasColumn .hides .isHidden .joinedBy .joinsTo .query .relationship .relationships .setDatabase .setSchema .table .toResource .update .validates #__safeSet__ #afterSave #beforeSave #calculate #changedFields #clearError #constructor #convert #destroy #destroyCascade #errorObject #fieldDefaultValue #fieldDefinitions #fieldList #get #getDataTypeOf #getErrors #getFieldData #hasChanged #hasErrors #hasField #include #inStorage #isFieldArray #isFieldPrimaryKey #joined #read #relationship #save #set #setError #setJoined #tableName #toObject ModelArray .from #constructor #destroyAll #destroyCascade #has #readAll #saveAll #setAll #toObject Scheduler #daily #hourly #minutely #restart #setApp #start #stop #weekly after allowOrigin badRequest before del error get getHeader getStatus notFound notImplemented options post put redirect render respond securityPolicy setHeader setHeaders status tooManyRequests unauthorized Authorizer #definePermission #permissible #permission ModelFactory .createFromModels .loadModels .populate #constructor #create WeeklyEntry #constructor #getDateOffset MinutelyEntry #constructor #getDateOffset ItemArray .from #constructor #setMeta #toObject HourlyEntry #constructor #getDateOffset StrongParam #constructor DailyEntry #constructor #getDateOffset GraphQuery .formatTree .parse .parseSyntaxTree .query #constructor #query Daemon #error #exit #idle #start #unwatch #watch endpoint Renderware #exec ExecutionQueue #exec #push #unshift #use Middleware #exec Task #exec handler listen logResponse

Composer(Model, parent)

The query composer (ORM)

Parameters

  • Model :
  • parent :

Instance members

#aggregate(alias, transformation)

Aggregates a field

aggregate(alias, transformation)

Aggregates a field

Parameters

  • String alias :

    The alias for the new aggregate field

  • Function transformation :

    The transformation to apply to create the aggregate

#constructor(Model, [parent])

Created by Model#query, used for composing SQL queries based on Models

constructor(Model, [parent])

Created by Model#query, used for composing SQL queries based on Models

Parameters

  • Nodal.Model Model :

    The model class the composer is querying from

  • [Nodal.Composer] parent (default null) :

    The composer's parent (another composer instance)

#end(callback)

Execute the query you've been composing.

end(callback)

Execute the query you've been composing.

Parameters

  • callback :

    The method to execute when the query is complete

#first(callback)

Shortcut for .limit(1).end(callback) that only returns a model object or error if not found

first(callback)

Shortcut for .limit(1).end(callback) that only returns a model object or error if not found

Parameters

  • Function callback :

    Callback to execute, provides an error and model parameter

#groupBy(column)

Groups by a specific field, or a transformation on a field

groupBy(column)

Groups by a specific field, or a transformation on a field

Parameters

  • String column :

    The column to group by

#join(joinName, comparisonsArray)

Join in a relationship.

join(joinName, comparisonsArray)

Join in a relationship.

Parameters

  • string joinName :

    The name of the joined relationship

  • array comparisonsArray :

    comparisons to perform on this join (can be overloaded)

#limit(offset, count)

Limit to an offset and count

limit(offset, count)

Limit to an offset and count

Parameters

  • number offset :

    The offset at which to set the limit. If this is the only argument provided, it will be the count instead.

  • number count :

    The number of results to be returned. Can be omitted, and if omitted, first argument is used for count.

Returns

Nodal.Composer :

new Composer instance

#orderBy(field, direction)

Order by field belonging to the current Composer instance's model.

orderBy(field, direction)

Order by field belonging to the current Composer instance's model.

Parameters

  • string field :

    Field to order by

  • string direction :

    Must be 'ASC' or 'DESC'

Returns

Nodal.Composer :

new Composer instance

#safeJoin(joinName, comparisonsArray)

Join in a relationship. Filters out hidden fields from comparisons.

safeJoin(joinName, comparisonsArray)

Join in a relationship. Filters out hidden fields from comparisons.

Parameters

  • string joinName :

    The name of the joined relationship

  • array comparisonsArray :

    comparisons to perform on this join (can be overloaded)

#safeWhere(comparisons, comparisonsArray)

Add comparisons to SQL WHERE clause. Does not allow filtering if Model.hides() has been called.

safeWhere(comparisons, comparisonsArray)

Add comparisons to SQL WHERE clause. Does not allow filtering if Model.hides() has been called.

Parameters

  • Object comparisons :

    Comparisons object. {age__lte: 27}, for example.

  • comparisonsArray :

Returns

Nodal.Composer :

new Composer instance

#update(fields, callback)

Execute query as an update query, changed all fields specified.

update(fields, callback)

Execute query as an update query, changed all fields specified.

Parameters

  • Object fields :

    The object containing columns (keys) and associated values you'd like to update

  • callback :

    The callback for the update query

#where(comparisons, comparisonsArray)

Add comparisons to SQL WHERE clause.

where(comparisons, comparisonsArray)

Add comparisons to SQL WHERE clause.

Parameters

  • Object comparisons :

    Comparisons object. {age__lte: 27}, for example.

  • comparisonsArray :

Returns

Nodal.Composer :

new Composer instance

SchedulerEntry(scheduler)

Base entry for schedulers for performing repeated tasks.

Parameters

  • scheduler :

Instance members

#constructor(scheduler)

constructor(scheduler)

Parameters

  • Nodal.Scheduler scheduler :

    The scheduler instance this entry belongs to

#exec

Execute the scheduler entry's associated task

exec

Execute the scheduler entry's associated task

#getDateOffset(cur)

Get the difference between now and the last time the task should be executed. Overwritten when inherited.

getDateOffset(cur)

Get the difference between now and the last time the task should be executed. Overwritten when inherited.

Parameters

  • Date cur :

    The current Date object

#perform(task, Task)

Assign a task to this scheduler entry

perform(task, Task)

Assign a task to this scheduler entry

Parameters

  • Nodal.Task or constructor task :

    The Task to perform (must have an exec function)

  • Task :
#start

Begin the scheduler entry. Create a timeout for the first execution, and an interval for all subsequent ones.

start

Begin the scheduler entry. Create a timeout for the first execution, and an interval for all subsequent ones.

#stop

Clear all timeouts and intervals for the scheduler entry (stops it).

stop

Clear all timeouts and intervals for the scheduler entry (stops it).

Model(modelData, fromStorage)

Basic Model implementation. Optionally interfaces with database.

Parameters

  • modelData :
  • fromStorage :

Static members

.calculates(calcField, fnCalculate, fnCompute)

Create a calculated field (in JavaScript). Must be synchronous.

calculates(calcField, fnCalculate, fnCompute)

Create a calculated field (in JavaScript). Must be synchronous.

Parameters

  • string calcField :

    The name of the calculated field

  • function fnCalculate :

    The synchronous method to perform a calculation for. Pass the names of the (non-computed) fields you'd like to use as parameters.

  • fnCompute :
.column(columnName)

Return the column schema data for a given name

column(columnName)

Return the column schema data for a given name

Parameters

.columnLookup

Get the model's column lookup data

columnLookup

Get the model's column lookup data

Returns

Object
.columnNames

Get the model's column names (fields)

columnNames

Get the model's column names (fields)

Returns

Array
.columns

Get the model's column data

columns

Get the model's column data

Returns

Array
.create(data, callback)

Creates a new model instance using the provided data.

create(data, callback)

Creates a new model instance using the provided data.

Parameters

  • object data :

    The data to load into the object.

  • callback :
.destroy(id, callback)

Finds and destroys a model with a specified id. Return a notFound error if model does not exist.

destroy(id, callback)

Finds and destroys a model with a specified id. Return a notFound error if model does not exist.

Parameters

  • number id :

    The id of the model you're looking for

  • callback :
.find(id, callback)

Finds a model with a provided id, otherwise returns a notFound error.

find(id, callback)

Finds a model with a provided id, otherwise returns a notFound error.

Parameters

  • number id :

    The id of the model you're looking for

  • callback :
.hasColumn(columnName)

Check if the model has a column name in its schema

hasColumn(columnName)

Check if the model has a column name in its schema

Parameters

.hides(field)

Hides fields from being output in .toObject() (i.e. API responses), even if asked for

hides(field)

Hides fields from being output in .toObject() (i.e. API responses), even if asked for

Parameters

.isHidden(field)

Tells us if a field is hidden (i.e. from API queries)

isHidden(field)

Tells us if a field is hidden (i.e. from API queries)

Parameters

.joinedBy(Model, options)

Specifies joinsTo for the child model

joinedBy(Model, options)

Specifies joinsTo for the child model

Parameters

  • Model :
  • options :
.joinsTo(Model, [options])

Sets a joins relationship for the Model. Sets joinedBy relationship for parent.

joinsTo(Model, [options])

Sets a joins relationship for the Model. Sets joinedBy relationship for parent.

Parameters

  • Model :
  • [Object] options (default {}) :

    "name": The string name of the parent in the relationship (default to camelCase of Model name) "via": Which field in current model represents this relationship, defaults to ${name}_id "as": What to display the name of the child as when joined to the parent (default to camelCase of child name) "multiple": Whether the child exists in multiples for the parent (defaults to false)

.query(db)

Creates a new Composer (ORM) instance to begin a new query.

query(db)

Creates a new Composer (ORM) instance to begin a new query.

Parameters

  • db :

Returns

Nodal.Composer
.relationship(name)

FIXME

relationship(name)

FIXME

Parameters

  • name :
.relationships

FIXME

relationships

FIXME

.setDatabase(db)

Set the database to be used for this model

setDatabase(db)

Set the database to be used for this model

Parameters

  • Nodal.Database db :
.setSchema(schema)

Set the schema to be used for this model

setSchema(schema)

Set the schema to be used for this model

Parameters

.table

Get the model's table name

table

Get the model's table name

Returns

string
.toResource(arrInterface)

Get resource data for a model, for API responses and debug information

toResource(arrInterface)

Get resource data for a model, for API responses and debug information

Parameters

  • Array arrInterface :

    Array of strings representing output columns, or singularly-keyed objects representing relationships and their interface.

Returns

Object :

Resource object for the model

.update(id, data, callback)

Finds and updates a model with a specified id. Return a notFound error if model does not exist.

update(id, data, callback)

Finds and updates a model with a specified id. Return a notFound error if model does not exist.

Parameters

  • number id :

    The id of the model you're looking for

  • object data :

    The data to load into the object.

  • callback :
.validates(field, message, fnAction)

Create a validator

validates(field, message, fnAction)

Create a validator

Parameters

  • string field :

    The field you'd like to validate

  • string message :

    The error message shown if a validation fails.

  • fnAction :

Instance members

#__safeSet__(field, value)

Sets specified field data for the model, assuming data is safe and does not log changes

__safeSet__(field, value)

Sets specified field data for the model, assuming data is safe and does not log changes

Parameters

  • string field :

    Field to set

  • any value :

    Value for the field

#afterSave(callback)

Logic to execute after a model saves. Intended to be overwritten when inherited.

afterSave(callback)

Logic to execute after a model saves. Intended to be overwritten when inherited.

Parameters

  • Function callback :

    Invoke with first argument as an error if failure.

#beforeSave(callback)

Logic to execute before a model saves. Intended to be overwritten when inherited.

beforeSave(callback)

Logic to execute before a model saves. Intended to be overwritten when inherited.

Parameters

  • Function callback :

    Invoke with first argument as an error if failure.

#calculate(field)

Calculate field from calculations (assumes it exists)

calculate(field)

Calculate field from calculations (assumes it exists)

Parameters

  • string field :

    Name of the calculated field

#changedFields

Provides an array of all changed fields since model was created / loaded from storage

changedFields

Provides an array of all changed fields since model was created / loaded from storage

Returns

Array
#clearError(key)

Clears all errors for a specified field

clearError(key)

Clears all errors for a specified field

Parameters

  • string key :

    The specified field for which to create the error (or '*' for generic)

Returns

boolean
#constructor(modelData, fromStorage)

constructor(modelData, fromStorage)

Parameters

  • Object modelData :

    Data to load into the object

  • fromStorage :
#convert(field, value)

Converts a value to its intended format based on its field. Returns null if field not found.

convert(field, value)

Converts a value to its intended format based on its field. Returns null if field not found.

Parameters

  • string field :

    The field to use for conversion data

  • any value :

    The value to convert

#destroy(callback)

Destroys model reference in database.

destroy(callback)

Destroys model reference in database.

Parameters

  • callback :
#destroyCascade(callback)

Destroys model and cascades all deletes.

destroyCascade(callback)

Destroys model and cascades all deletes.

Parameters

  • function callback :

    method to run upon completion

#errorObject

Creates an error object for the model if any validations have failed, returns null otherwise

errorObject

Creates an error object for the model if any validations have failed, returns null otherwise

Returns

Error
#fieldDefaultValue(field)

Retrieve the defaultValue for this field from our schema

fieldDefaultValue(field)

Retrieve the defaultValue for this field from our schema

Parameters

Returns

any
#fieldDefinitions

Retrieve our field schema definitions

fieldDefinitions

Retrieve our field schema definitions

Returns

Array
#fieldList

Retrieve an array of fields for our model

fieldList

Retrieve an array of fields for our model

Returns

Array
#get(field, ignoreFormat)

Retrieve field data for the model.

get(field, ignoreFormat)

Retrieve field data for the model.

Parameters

  • string field :

    Field for which you'd like to retrieve data.

  • ignoreFormat :
#getDataTypeOf(field)

Retrieve the schema data type for the specified field

getDataTypeOf(field)

Retrieve the schema data type for the specified field

Parameters

Returns

string
#getErrors

Gives us an error object with each errored field as a key, and each value being an array of failure messages from the validators

getErrors

Gives us an error object with each errored field as a key, and each value being an array of failure messages from the validators

Returns

Object
#getFieldData(field)

Retrieve the schema field data for the specified field

getFieldData(field)

Retrieve the schema field data for the specified field

Parameters

Returns

Object
#hasChanged(field)

Tells us whether a model field has changed since we created it or loaded it from storage.

hasChanged(field)

Tells us whether a model field has changed since we created it or loaded it from storage.

Parameters

  • string field :

    The model field

Returns

boolean
#hasErrors

Tells us whether or not the model has errors (failed validations)

hasErrors

Tells us whether or not the model has errors (failed validations)

Returns

boolean
#hasField(field)

Determine if the model has a specified field.

hasField(field)

Determine if the model has a specified field.

Parameters

Returns

boolean
#include(callback)

Retrieve associated models joined this model from the database.

include(callback)

Retrieve associated models joined this model from the database.

Parameters

  • callback :
#inStorage

Indicates whethere or not the model is currently represented in hard storage (db).

inStorage

Indicates whethere or not the model is currently represented in hard storage (db).

Returns

boolean
#isFieldArray(field)

Determine whether or not this field is an Array (PostgreSQL supports this)

isFieldArray(field)

Determine whether or not this field is an Array (PostgreSQL supports this)

Parameters

Returns

boolean
#isFieldPrimaryKey(field)

Determine whether or not this field is a primary key in our schema

isFieldPrimaryKey(field)

Determine whether or not this field is a primary key in our schema

Parameters

Returns

boolean
#joined(joinName)

Retrieves joined Model or ModelArray

joined(joinName)

Retrieves joined Model or ModelArray

Parameters

  • String joinName :

    the name of the join (list of connectors separated by __)

#read(data)

Reads new data into the model.

read(data)

Reads new data into the model.

Parameters

  • Object data :

    Data to inject into the model

Returns

this
#relationship(name)

Grabs the path of the given relationship from the RelationshipGraph

relationship(name)

Grabs the path of the given relationship from the RelationshipGraph

Parameters

  • string name :

    the name of the relationship

#save(callback)

Save a model (execute beforeSave and afterSave)

save(callback)

Save a model (execute beforeSave and afterSave)

Parameters

  • Function callback :

    Callback to execute upon completion

#set(field, value)

Sets specified field data for the model. Logs and validates the change.

set(field, value)

Sets specified field data for the model. Logs and validates the change.

Parameters

  • string field :

    Field to set

  • any value :

    Value for the field

#setError(key, message)

Set an error for a specified field (supports multiple errors)

setError(key, message)

Set an error for a specified field (supports multiple errors)

Parameters

  • string key :

    The specified field for which to create the error (or '*' for generic)

  • string message :

    The error message

Returns

boolean
#setJoined(field, value)

Set a joined object (Model or ModelArray)

setJoined(field, value)

Set a joined object (Model or ModelArray)

Parameters

  • string field :

    The field (name of the join relationship)

  • Model or ModelArray value :

    The joined model or array of models

#tableName

Get the table name for the model.

tableName

Get the table name for the model.

Returns

string
#toObject(arrInterface)

Creates a plain object from the Model, with properties matching an optional interface

toObject(arrInterface)

Creates a plain object from the Model, with properties matching an optional interface

Parameters

  • Array arrInterface :

    Interface to use for object creation

ModelArray(modelConstructor)

Array of Models, for easy conversion to Objects

Parameters

  • modelConstructor :

Static members

.from(arr)

Convert a normal Array into a ModelArray

from(arr)

Convert a normal Array into a ModelArray

Parameters

  • Array arr :

    The array of child objects

Instance members

#constructor(modelConstructor)

Create the ModelArray with a provided Model to use as a reference.

constructor(modelConstructor)

Create the ModelArray with a provided Model to use as a reference.

Parameters

  • modelConstructor :
#destroyAll(callback)

Destroys (deletes) all models in the ModelArray from the database

destroyAll(callback)

Destroys (deletes) all models in the ModelArray from the database

Parameters

  • function callback :

    Method to invoke upon completion

#destroyCascade(callback)

Destroys model and cascades all deletes.

destroyCascade(callback)

Destroys model and cascades all deletes.

Parameters

  • function callback :

    method to run upon completion

#has(model)

Checks if ModelArray has a model in it

has(model)

Checks if ModelArray has a model in it

Parameters

  • Nodal.Model model :
#readAll(Object, data)

Calls Model#read on each Model in the ModelArray

readAll(Object, data)

Calls Model#read on each Model in the ModelArray

Parameters

  • Object :
  • data :
#saveAll(callback)

Saves / updates all models in the ModelArray. Uses beforeSave / afterSave. Will return an error and rollback if any model errors out.

saveAll(callback)

Saves / updates all models in the ModelArray. Uses beforeSave / afterSave. Will return an error and rollback if any model errors out.

Parameters

  • function callback :

    returning the error and reference to self

#setAll(Object, field, value)

Calls Model#read on each Model in the ModelArray

setAll(Object, field, value)

Calls Model#read on each Model in the ModelArray

Parameters

  • Object :
  • field :
  • value :
#toObject(arrInterface)

Creates an Array of plain objects from the ModelArray, with properties matching an optional interface

toObject(arrInterface)

Creates an Array of plain objects from the ModelArray, with properties matching an optional interface

Parameters

  • Array arrInterface :

    Interface to use for object creation for each model

Scheduler

Use to delegate tasks minutely, hourly, daily, or weekly.

Instance members

#daily

Construct a new Nodal.DailyEntry. All arguments passed represent the times to execute.

daily

Construct a new Nodal.DailyEntry. All arguments passed represent the times to execute.

#hourly

Construct a new Nodal.HourlyEntry. All arguments passed represent the times to execute.

hourly

Construct a new Nodal.HourlyEntry. All arguments passed represent the times to execute.

#minutely

Construct a new Nodal.MinutelyEntry. All arguments passed represent the times to execute.

minutely

Construct a new Nodal.MinutelyEntry. All arguments passed represent the times to execute.

#restart

Restarts all associated SchedulerEntry objects for the Scheduler

restart

Restarts all associated SchedulerEntry objects for the Scheduler

#setApp(app)

Set the app for the scheduler.

setApp(app)

Set the app for the scheduler.

Parameters

  • Nodal.Application app :

    Your Nodal application

#start

Starts all associated SchedulerEntry objects for the Scheduler

start

Starts all associated SchedulerEntry objects for the Scheduler

#stop

Stops all associated SchedulerEntry objects for the Scheduler

stop

Stops all associated SchedulerEntry objects for the Scheduler

#weekly

Construct a new Nodal.WeeklyEntry. All arguments passed represent the times to execute.

weekly

Construct a new Nodal.WeeklyEntry. All arguments passed represent the times to execute.

after

Intended to be overwritten when inherited. Run after renderware.

allowOrigin(value)

Specifies CORS (cross origin resource sharing) headers.

Parameters

  • string value :

    Use '*' for a generic API service that accepts requests from anywhere, otherwise specific a domain.

Returns

this

badRequest(msg, details)

Using API formatting, send an http.ServerResponse indicating there was a Bad Request (400)

Parameters

  • string msg :

    Error message to send

  • Object details :

    Any additional details for the error (must be serializable)

Returns

boolean

before

Intended to be overwritten when inherited. Run before middleware. Controller-specific middleware and renderware here

del

Method called when a route is hit with a DELETE request, if not first intercepted by custom Controller#destroy method. Intended to be overwritten when inherited.

error(msg, details)

Using API formatting, send an http.ServerResponse indicating there was an Internal Server Error (500)

Parameters

  • string msg :

    Error message to send

  • Object details :

    Any additional details for the error (must be serializable)

Returns

boolean

get

Method called when a route is hit with a GET request, if not first intercepted by custom Controller#index or Controller#show methods. Intended to be overwritten when inherited.

getHeader(key, value)

Get the value of a specific response header

Parameters

  • String key :
  • String value :

    Default value returned if not found

getStatus

The current HTTP status code expected to be used by the outgoing http.ServerResponse

Returns

number

notFound(msg, details)

Using API formatting, send an http.ServerResponse indicating the requested resource was Not Found (404)

Parameters

  • string msg :

    Error message to send

  • Object details :

    Any additional details for the error (must be serializable)

Returns

boolean

notImplemented(msg, details)

Endpoint not implemented

Parameters

  • string msg :

    Error message to send

  • Object details :

    Any additional details for the error (must be serializable)

Returns

boolean

options

Method called when a route is hit with an OPTIONS request. Typically unused, exists for CORS purposes.

post

Method called when a route is hit with a POST request, if not first intercepted by custom Controller#create method. Intended to be overwritten when inherited.

put

Method called when a route is hit with a PUT request, if not first intercepted by custom Controller#update method. Intended to be overwritten when inherited.

redirect(location)

Creates a 302 redirect to the desired location

Parameters

render(data)

Render an HTTP response (end ServerResponse) based on provided data

Parameters

  • Object data :

    Can be Buffer, String, or Plain Object

respond(data, arrInterface)

Using API formatting, generate an error or respond with model / object data.

Parameters

  • Error or Object or Array or Nodal.Model or Nodal.ModelArray data :

    Object to be formatted for API response

  • arrInterface :

Returns

boolean

securityPolicy(directive, src)

Add Content-Security-Policy headers

Parameters

  • string directive :

    The directive of the security policy

  • string src :

    The value (domain) to add to the policy

setHeader(key, value)

Set a specific response header

Parameters

setHeaders(object)

Set HTTP headers to be used by the outgoing http.ServerResponse

Parameters

  • Object object :

    Object containing key-value pairs for HTTP headers

Returns

Object :

The headers object created

status(code)

Set HTTP status code for this response

Parameters

tooManyRequests(msg, details)

Using API formatting, send an http.ServerResponse indicating there were Too Many Requests (429) (i.e. the client is being rate limited)

Parameters

  • string msg :

    Error message to send

  • Object details :

    Any additional details for the error (must be serializable)

Returns

boolean

unauthorized(msg, details)

Using API formatting, send an http.ServerResponse indicating there was an Unauthorized request (401)

Parameters

  • string msg :

    Error message to send

  • Object details :

    Any additional details for the error (must be serializable)

Returns

boolean

Authorizer

Intercepts requests to controller using Controller#authorize. Use with app using Application#useAuthorizer.

Instance members

#definePermission(permissionName, value)

Associates a permission name with an integer value.

definePermission(permissionName, value)

Associates a permission name with an integer value.

Parameters

  • string permissionName :

    The permission name, eg. "admin"

  • number value :

    The value, will be cast to signed 32-bit int

Returns

boolean
#permissible(permissionName, permissionLevel)

Lets us know if, given a permissionName, an associated numeric value (level) is valid

permissible(permissionName, permissionLevel)

Lets us know if, given a permissionName, an associated numeric value (level) is valid

Parameters

  • string permissionName :

    The permission name, eg. "admin"

  • number permissionLevel :

    A numeric value (preferably integer) to test

Returns

boolean
#permission(permissionName)

Provides the integer value of a permissionName, as defined by Authorizer#definePermission

permission(permissionName)

Provides the integer value of a permissionName, as defined by Authorizer#definePermission

Parameters

  • string permissionName :

    The permission name, eg. "admin"

Returns

number

ModelFactory(modelConstructor)

Factory for creating models

Parameters

  • modelConstructor :

Static members

.createFromModels(Models, objModelData, callback)

Creates new factories from a supplied array of Models, loading in data keyed by Model name

createFromModels(Models, objModelData, callback)

Creates new factories from a supplied array of Models, loading in data keyed by Model name

Parameters

  • Array Models :

    Array of model constructors you wish to reference

  • Object objModelData :

    Keys are model names, values are arrays of model data you wish to create

  • Function callback :

    What to execute upon completion

.loadModels

Loads all model constructors in your ./app/models directory into an array

loadModels

Loads all model constructors in your ./app/models directory into an array

Returns

Array :

Array of model Constructors

.populate(Models, objModelData, callback)

Populates a large amount of model data from an Object.

populate(Models, objModelData, callback)

Populates a large amount of model data from an Object.

Parameters

  • Array Models :

    Array of Model constructors

  • objModelData :
  • callback :

Instance members

#constructor(modelConstructor)

Create the ModelFactory with a provided Model to use as a reference.

constructor(modelConstructor)

Create the ModelFactory with a provided Model to use as a reference.

Parameters

  • Nodal.Model modelConstructor :

    Must pass the constructor for the type of ModelFactory you wish to create.

#create(arrModelData, callback)

Creates models from an array of Objects containing the model data

create(arrModelData, callback)

Creates models from an array of Objects containing the model data

Parameters

  • Array arrModelData :

    Array of objects to create model data from

  • callback :

WeeklyEntry(scheduler, times)

SchedulerEntry extension for weekly (on the day of week) execution

Parameters

  • scheduler :
  • times :

Instance members

#constructor(scheduler, times)

constructor(scheduler, times)

Parameters

  • Nodal.Scheduler scheduler :

    the scheduler the entry belongs to

  • Array times :

    The times (in days of week) to execute the task

#getDateOffset(cur)

Sets the offset to the nearest week

getDateOffset(cur)

Sets the offset to the nearest week

Parameters

  • Date cur :

    The current Date

MinutelyEntry(scheduler, times)

SchedulerEntry extension for minutely (on the second) execution

Parameters

  • scheduler :
  • times :

Instance members

#constructor(scheduler, times)

constructor(scheduler, times)

Parameters

  • Nodal.Scheduler scheduler :

    the scheduler the entry belongs to

  • Array times :

    The times (in seconds) to execute the task

#getDateOffset(cur)

Sets the offset to the nearest minute

getDateOffset(cur)

Sets the offset to the nearest minute

Parameters

  • Date cur :

    The current Date

ItemArray

Array of Items, for easy conversion to Objects

Static members

.from(arr)

Convert a normal Array into a ItemArray

from(arr)

Convert a normal Array into a ItemArray

Parameters

  • Array arr :

    The array of child objects

Instance members

#constructor

Create the ItemArray

constructor

Create the ItemArray

#setMeta(data)

Sets metadata for the modelArray

setMeta(data)

Sets metadata for the modelArray

Parameters

#toObject(arrInterface)

Creates an Array of plain objects from the ModelArray, with properties matching an optional interface

toObject(arrInterface)

Creates an Array of plain objects from the ModelArray, with properties matching an optional interface

Parameters

  • Array arrInterface :

    Interface to use for object creation for each model

HourlyEntry(scheduler, times)

SchedulerEntry extension for hourly (on the minute) execution

Parameters

  • scheduler :
  • times :

Instance members

#constructor(scheduler, times)

constructor(scheduler, times)

Parameters

  • Nodal.Scheduler scheduler :

    the scheduler the entry belongs to

  • Array times :

    The times (in minutes) to execute the task

#getDateOffset(cur)

Sets the offset to the nearest hour

getDateOffset(cur)

Sets the offset to the nearest hour

Parameters

  • Date cur :

    The current Date

StrongParam(props)

Used to filter parameters from HTTP query string or body data

Parameters

  • props :

Instance members

#constructor(object, props)

constructor(object, props)

Parameters

  • props object :

    Properties

  • props :

DailyEntry(scheduler, times)

SchedulerEntry extension for daily (on the hour) execution

Parameters

  • scheduler :
  • times :

Instance members

#constructor(scheduler, times)

constructor(scheduler, times)

Parameters

  • Nodal.Scheduler scheduler :

    the scheduler the entry belongs to

  • Array times :

    The times (in hours) to execute the task

#getDateOffset(cur)

Sets the offset to the nearest day

getDateOffset(cur)

Sets the offset to the nearest day

Parameters

  • Date cur :

    The current Date

GraphQuery(str, maxDepth, Model)

GraphQuery class that translates GraphQL to something digestible by the Composer

Parameters

  • str :
  • maxDepth :
  • Model :

Static members

.formatTree(tree, max, joins, parents)

Format a parsed syntax tree in a way that the Composer expects

formatTree(tree, max, joins, parents)

Format a parsed syntax tree in a way that the Composer expects

Parameters

  • tree :
  • max :
  • joins :
  • parents :
.parse(str, max)

Fully parse a GraphQL query, get necessary joins to make in SQL

parse(str, max)

Fully parse a GraphQL query, get necessary joins to make in SQL

Parameters

  • str :
  • max :
.parseSyntaxTree(str, state, arr)

Parse syntax tree of a GraphQL query

parseSyntaxTree(str, state, arr)

Parse syntax tree of a GraphQL query

Parameters

  • str :
  • state :
  • arr :
.query(str, maxDepth, callback)

Create and execute a GraphQuery object

query(str, maxDepth, callback)

Create and execute a GraphQuery object

Parameters

  • String str :

    The query to execute

  • Number maxDepth :

    The maximum depth of graph to traverse

  • Function callback :

    The function to execute upon completion

Instance members

#constructor(str, maxDepth, [Model])

Create a GraphQuery object

constructor(str, maxDepth, [Model])

Create a GraphQuery object

Parameters

  • String str :

    The query to execute

  • Number maxDepth :

    The maximum depth of graph to traverse

  • [Nodal.Model] Model (default null) :

    The Model to base your query around (used for testing)

#query(callback)

Query the GraphQuery object from the database

query(callback)

Query the GraphQuery object from the database

Parameters

  • Function callback :

    The function to execute upon completion

Daemon

Multi-process HTTP Daemon that resets when files changed (in development)

Instance members

#error(error)

Log an error on the Daemon

error(error)

Log an error on the Daemon

Parameters

#exit(child, code)

Shut down a child process given a specific exit code. (Reboot if clean shutdown.)

exit(child, code)

Shut down a child process given a specific exit code. (Reboot if clean shutdown.)

Parameters

  • child_process child :
  • Number code :

    Exit status codes

#idle

Daemon failed to load, set it in idle state (accept connections, give dummy response)

idle

Daemon failed to load, set it in idle state (accept connections, give dummy response)

#start(port)

Starts the Daemon. If all application services fail, will launch a dummy error app on the port provided.

start(port)

Starts the Daemon. If all application services fail, will launch a dummy error app on the port provided.

Parameters

#unwatch

Stops watching a directory tree for changes

unwatch

Stops watching a directory tree for changes

#watch(path, onChange)

Watches a directory tree for changes

watch(path, onChange)

Watches a directory tree for changes

Parameters

  • string path :

    Directory tree to watch

  • function onChange :

    Method to be executed when a change is detected

endpoint(path, query)

Creates a new MockRequest object (emulates an HTTP request)

Parameters

  • string path :

    The path you wish to hit

  • Object query :

    The query parameters you wish to pass

Returns

Nodal.EndpointRequest

Renderware

Do not need to extend from this class for new Renderware, just use this as a reference template.

Instance members

#exec(controller, data, callback)

Execute the renderware.

exec(controller, data, callback)

Execute the renderware.

Parameters

  • Nodal.Controller controller :

    the Controller Instance

  • string or Buffer data :

    The data about the be rendered

  • callback :

ExecutionQueue

Queues middleware, renderware, etc (make sure they fire in order).

Instance members

#exec

Execute all items, in order. First parameter is a "steady" object that will be passed by reference to every item in the queue as the first parameter of exec. Middle parameters are passed by previous item#exec calls (as parameters, after err), and last parameter is a completion callback.

exec

Execute all items, in order. First parameter is a "steady" object that will be passed by reference to every item in the queue as the first parameter of exec. Middle parameters are passed by previous item#exec calls (as parameters, after err), and last parameter is a completion callback.

#push

Alias for ExecutionQueue#use

push

Alias for ExecutionQueue#use

#unshift(arguments)

Tell the manager to put an object in the queue (first)

unshift(arguments)

Tell the manager to put an object in the queue (first)

Parameters

  • Object arguments :

    The item constructor (must have exec function) plus other arguments you wish to add to the queue.

#use(arguments)

Tell the manager to put an object in the queue (last)

use(arguments)

Tell the manager to put an object in the queue (last)

Parameters

  • Object arguments :

    The item constructor (must have exec function) plus other arguments you wish to add to the queue.

Middleware

Do not need to extend from this class for new Middleware, just use this as a reference template.

Instance members

#exec(controller, data, callback)

Execute the middleware.

exec(controller, data, callback)

Execute the middleware.

Parameters

  • Nodal.Controller controller :

    the Controller Instance

  • string or Buffer data :

    The data about the be rendered

  • callback :

Task

Do not need to extend from this class for new Tasks, just use this as a reference template.

Instance members

#exec(app, arguments, args, callback)

Execute the task

exec(app, arguments, args, callback)

Execute the task

Parameters

  • Nodal.Application app :

    the Application Instance

  • object arguments :

    passed to the task on the command line

  • args :
  • callback :

handler(req, res)

HTTP Request Handler

Parameters

  • http.ClientRequest req :
  • http.ServerResponse res :

listen(port)

Listens for incoming connections on a provided port

Parameters

logResponse(statusCode, url, t, str)

Logs a server response in the console

Parameters

  • Number statusCode :

    HTTP Status Code

  • String url :

    The url that was hit

  • String t :

    The time to execute the request

  • str :