api/lib/countly.model

This module loads existing model or create one from default module if it does not exist

Source:

Methods

(static) create(fetchValueopt) → {module:api/lib/countly.model~countlyMetric}

Source:

Create Countly data model to process data segment from fetched from server

Example
var countlyModel = require("api/lib/countly.mode.js");
var countlyDensity = countlyModel.create(function(val, data, separate){
     if(separate){
         //request separated/unprocessed data
         return val;
     }
     else{
         //we can preprocess data and group, for example, by first letter
         return val[0];
     }
});
Parameters:
Name Type Attributes Description
fetchValue function <optional>

default function to fetch and transform if needed value from standard data model

Returns:

new countly metric model

Type
module:api/lib/countly.model~countlyMetric

(static) load(segment) → {module:api/lib/countly.model~countlyMetric}

Source:

Loads countly model for provided data if it already exists in api/lib folder or in plugins, or creates new one from default model if it does not exist

Example
var countlyModel = require("api/lib/countly.mode.js");
var countlyDensity = countlyModel.load("densities");
Parameters:
Name Type Description
segment string

data segment name to process

Returns:

countly metric model for provided name

Type
module:api/lib/countly.model~countlyMetric