Model

Apperyio.getModel(modelName, default).

The Model helps define app model (object) in an app.

Method Summary

Model has the following method:

Method

Description

Apperyio.getModel(modelName, default)

Creates a model object by its name or returns TypeNotFoundError if model type not found.

Parameters Summary

Method has the following parameters:

Parameter

Description

Required

modelName

Model name described in Project > Model and Storage > Model view.

Yes.

default

Data to be used when an object is created.

No.

Examples

Let's say an app has the following model defined:

Product (Object)
  name (String)
  partNumber (Integer)
The following code will create an empty Product object:

var p = Apperyio.getModel("Product");
console.log(p);
{partNumber: 0, name: ""}
The following code will create a model object with default data:
var modelData = {"name":"Smartphone", "partNumber": 1000};
var p = Apperyio.getModel("Product", modelData);
console.log(p);
{partNumber: 1000, name: "Smartphone"}