Waterline.avg()

Return the average of the values of a selected attribute for records matching the specified criteria.

Usage

Hover over inputs/exits for more info.

var Waterline = require('machinepack-waterline');


// Return the average of the values of a selected attribute for records matching the specified criteria.

Waterline.avg({

model: 'user',

attribute: 'age',

where: {},

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// The provided `where` was invalid.

invalidCriteria: function () {

 

},

// The provided attribute was invalid.

invalidAttribute: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

model required

'user'
attribute required

'age'
where

{}

Exits

error

An unexpected error occurred.

invalidCriteria

The provided `where` was invalid.

invalidAttribute

The provided attribute was invalid.

success

OK.

123