API Builder ORM






No Maintenance Data Available





Type Definitions





Object relational mapping (ORM) framework for API Builder.

Main Components

There are 4 main components to the ORM framework:


To define a model, you must give a set of fields and a connector.

var User = orm.Model.extend('user',{
    fields: {
        name: {
            type: String,
            default: 'Jeff',
    connector: Connector

The first argument is the name of the model. The second argument is the definition of the model.


The definition of the model is an object with the following properties.

actionsstring[]An array of method actions that are enabled for the model. If empty, all are enabled.
autogenbooleanA boolean to indicate the model was auto-generated.
cachebooleanEnables a LRU cache.
connectorstring | objectIdentifies the connector to which this model belongs, required.
countDescriptionstringChanges the description for the method count.
createDescriptionstringChanges the description for the method create.
deleteAllDescriptionstringChanges the description for the method deleteAll.
deleteDescriptionstringChanges the description for the method delete.
disabledActionsstring[]An array of actions that are disabled for the model.
distinctDescriptionstringChanges the description for the method distinct.
fieldsobjectA collection of property fields belonging to the model.
findAllDescriptionstringChanges the description for the method findAll.
findAndModifyDescriptionstringChanges the description for the method findAndModify.
findByIDDescriptionstringChanges the description for the method findByID.
findManyByIDDescriptionstringChanges the description for the method findManyByID.
metadataobjectAdditional metadata about the model.
pluralstringThe plural name of the model.
queryDescriptionstringChanges the description for the method query.
singularstringThe singular name of the model.
updateDescriptionstringChanges the description for the method update.
upsertDescriptionstringChanges the description for the method upsert.


The fields are a collection of properties where each key uniquely identifies the field, and each field has a set of properties that define it:

custombooleanIndicates the field's value is custom and should be omitted when converting to payload (e.g. JSON).
defaultanyThe default value.
descriptionstringThe description of the field.
lengthintegerFor Strings and Arrays, the precise length of the field.
limitintegerIn composite models where the field is joined with another and the type is "array", then this property limits the amount of records returned.
maxlengthintegerFor Strings and Arrays, the maximum length of the field.
minlengthintegerFor Strings and Arrays, the minimum length of the field.
modelstringThe name of the model from which this field originates (in composite models).
namestringThe name of the field.
optionalbooleanThe field is optional (deprecated).
readonlybooleanThe field is read-only.
requiredbooleanIf true, the field is required.
typeanyThe column type, supporting values: string, date, number, array, object, and boolean; required.


The metadata is used to encode additional data about the Model that can be used for composite models or primary keys.

primarykeystringThe field name that is identified as the primary key. The field cannot be a property of fields.
primaryKeyDetailsobjectAn object that describes additional details about the primary key.
tablestringIn some connectors, this refers to the table name for the Model.
schemastringIn some connectors, this refers to the table schema name or owner of the table for the Model.
autogeneratedbooleanIndicates the primary key is auto-generated.
dataTypestringIn some connectors, this describes the persisted datatype of the primary key.
typestringIn some connectors, this describes the field type for the primary key, supporting values: string, date, number.


The model has several instance methods:

countFind count of a query.
createCreate a new Model instance.
deleteDeletes a Model instance.
deleteAllRemoves all Model instances.
distinctFind unique values for a Model field name.
extendCreate a new Model class from the current Model.
findFind one or more Models.
findAllFind all Models.
findAndModifyFind a Model from a query and modify values.
findByIDFind one Model by a primary key.
findManyByIDFind many Models by a primary key.
queryFind a Model from a query.
updateUpdates a Model instance.
upsertUpdates or inserts a Model instance.

Custom functions

A model can have custom functions by defining them in the definition as a property. They will automatically be available on the model instance.

var User = orm.Model.extend('user',{
    fields: {
        name: {
            type: String,
            required: true,
            default: 'jeff'
    connector: Connector,

    // implement a function that will be on the Model and
    // available to all instances
    getProperName: function() {
        // this points to the instance when this is invoked
        return +;



One you've defined a model, you can then use it to create an Instance of the Model.

User.create({name:'Nolan'}, function(err,user){
    // you now have a user instance

Instances has several methods for dealing with the model.

getget the value of a field property
setset a value or a set of values (Object)
isUnsavedreturns true if the instance has pending changes
isDeletedreturns true if the instance has been deleted and cannot be used
updatesave any pending changes
removeremove this instance (delete it)
getPrimaryKeyreturn the primary key value set by the Connector

In addition to get and set, you can also use property accessors to get field values.

console.log('name is',; = 'Rick';


If the Connector returns more than one Model instance, it will return it as a Collection, which is a container of Model instances.

A collection is an array and has additional helper functions for manipulating the collection.

You can get the length of the collection with the length property.


To create a connector, you can either inherit from the Connector class using utils.inherit or extend:

var MyConnector = orm.Connector.extend({
    constructor: function(){
    findByID: function(Model, id, callback) {

Once you have created a Connector class, you can create a new instance:

var connector = new MyConnector({
    url: ''


This code is proprietary, closed source software licensed to you by Axway. All Rights Reserved. You may not modify Axway’s code without express written permission of Axway. You are licensed to use and distribute your services developed with the use of this software and dependencies, including distributing reasonable and appropriate portions of the Axway code and dependencies. Except as set forth above, this code MUST not be copied or otherwise redistributed without express written permission of Axway. This module is licensed as part of the Axway Platform and governed under the terms of the Axway license agreement (General Conditions) located here:; EXCEPT THAT IF YOU RECEIVED A FREE SUBSCRIPTION, LICENSE, OR SUPPORT SUBSCRIPTION FOR THIS CODE, NOTWITHSTANDING THE LANGUAGE OF THE GENERAL CONDITIONS, AXWAY HEREBY DISCLAIMS ALL SUPPORT AND MAINTENANCE OBLIGATIONS, AS WELL AS ALL EXPRESS AND IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO IMPLIED INFRINGEMENT WARRANTIES, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, AND YOU ACCEPT THE PRODUCT AS-IS AND WITH ALL FAULTS, SOLELY AT YOUR OWN RISK. Your right to use this software is strictly limited to the term (if any) of the license or subscription originally granted to you.

Rate & Review

Great Documentation0
Easy to Use0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Unwelcoming Community0