LocalSailsApps.buildModel()

Build a JavaScript code string for a Sails.js model using the provided metadata.

Usage

Hover over inputs/exits for more info.

var LocalSailsApps = require('machinepack-local-sails-apps');


// Build a JavaScript code string for a Sails.js model using the provided metadata.

LocalSailsApps.buildModel({

modelDef: { description: 'a foo', friendlyName: 'Foo', globalId: 'Foo', identity: 'foo', primaryKey: { type: 'string', example: '*' }, attributes: [ { defaultsTo: 'foobar', example: '*', name: 'testtype', required: false, type: 'string', unique: false } ] },

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

modelDef required

A definition of a model built in Treeline

{ description: 'a foo',
  friendlyName: 'Foo',
  globalId: 'Foo',
  identity: 'foo',
  primaryKey: { type: 'string', example: '*' },
  attributes: 
   [ { defaultsTo: 'foobar',
       example: '*',
       name: 'testtype',
       required: false,
       type: 'string',
       unique: false } ] }

Exits

error

An unexpected error occurred.

N/A

success

OK.

'{friendlyName: "foo", identity: "foo" ... }'