ModelDefinitions

model. ModelDefinitions

Contains all the ModelDefinitions that are available. The definitions are properties on the object. This would be used as a main entry point to do any interaction.

After calling the initialise function d2({baseUrl: 'dhis/api'}) this object is the models property that allows you to access

Constructor

new ModelDefinitions()

Source:
Example
models.dataElement.getList();

Methods

add(modelDefinition)

Source:

This will allow you to add your own custom ModelDefinitions.

The Definition object should have the following properties modelName, modelNamePlural, modelOptions, properties, validations

Example
models.add({name: 'MyDefinition', plural: 'MyDefinitions', endPointname: '/myDefinition'});
Parameters:
Name Type Description
modelDefinition ModelDefinition

Add a model definition to the definitions collection

mapThroughDefinitions(transformer) → {Array}

Source:

Map through the modelDefinitions like you would with a simple Array.map()

Example
models.mapThroughDefinitions(definition => console.log(definition.name);
Parameters:
Name Type Description
transformer function

Transformer function that will be run for each ModelDefinition

Returns:

Array with the ModelDefinition objects.

Type
Array