sails-hook-blueprint-sum

0.1.0 • Public • Published

sails-hook-blueprint-sum

Directly based on Kristian Ackar's package Sails-hook-blueprint-count.

Adds blueprint api method to sum values of attribute(s) on records in database. This is useful for example get a total amount of transactions.

The sum function comes from here.

Installation

In Sails.js v0.11+ installed hooks are run automatically. Therefore, simply install the hook via npm:

npm install sails-hook-blueprint-sum

Usage

GET /:model/sum?where={:CRITERIA}&sum=:attribute1&sum=:attribute2

"where" parameter is optional. If it's used it's used in the same way like you use it in default blueprint api find method Sails.js blueprint api find method documentation.

"sum" attribute is mandatory and errors will be raised if attributes are not compliant to the sum function. Handling of these errors is not implented yet, thus it's a 0.0.1 version.

Readme

Keywords

Package Sidebar

Install

npm i sails-hook-blueprint-sum

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • gregkapustin