Skip to content

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.

License

Notifications You must be signed in to change notification settings

GregKapustin/sails-hook-blueprint-sum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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. Adds also max method.

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
GET /:model/max?where={:CRITERIA}&max=:attribute1&max=: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.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published