This is a sailsjs library that helps you integrate count (Javascript count) with your sails app.
This library would help you easily query your sails endpoint for datasets that is easily understood by javascript count. It works like blueprint, so you can imagine how easy it must be to use. Try and testify!!!
npm install sails-count --save
Just like blueprint actions a count action is automatically available on all models for you.
//assuming you have a model User
/user/count
//or if you have a prefix api
/api/user/count
The count action automatically inherits its parent policies.
//in config/policies.js
module.exports.policies = {
// all count route inherit this by default.
'*': [
'hasToken',
'isAuthenticated',
'ModelPolicy',
'PermissionPolicy',
'RolePolicy'
],
// user/count route would not be bound by any policy
UserController: [],
// rabbit/count route would only inherit these two policies
RabbitController: [
'hasToken',
'isAuthenticated'
],
// payment/count route would only inherit this one policy
PaymentController: {
'count':[
'isAuthenticated'
]
}
}
Send a GET
or POST
to /model/count
or /api/model/count
if you have the api prefix turned on in blueprint.
Please rely on count's Documentation for your implementation on the frontend.
vm.dtOptions = {
...
processing: true,
serverSide: true,
ajax: {
//the url to the model/count
url: 'https://#######/model/count',
//You can use either a GET or POST verb
type: 'GET',
dataSrc: "aaData"
},
...
}
Nested data are automatically populated for you using the dot notations in your count options column definition
vm.dtOptions = {
...
aoColumns: [
{
mData: "trackingNumber"
},
{
mData: "address.city"
},
{
mData: "status"
},
{
mData: "createdAt",
bSortable: true,
mRender: function (data, type, row, meta) {
return helper.getHumanReadableDate(row.createdAt);
}
}
],
...
}
You can add some extra data to your request to perform advanced functions like filter
or range
on a particular query. Cool rite :-)
?
{
//filter only records that have a color of yellow
data: "color",
searchable: true,
search: {
value: "yellow"
}
};
or
{
data: "createdAt",
//Just make searchable true in your case,
//I only wanted to make sure the dates were good
//for the server before sending
searchable: moment(vm.range.fromDate).isValid() && moment(vm.range.toDate).isValid(),
search: {
value: {
//Make sure you send dates in a format sails understand
//This method also works for integers and strings.
//Can be used to get data whose values fall within a range
from: helper.getISOServerReadableDate(vm.range.fromDate),
to: helper.getISOServerReadableDate(vm.range.toDate)
}
}
}
If you have an idea for a new feature, please feel free to submit it as a pull request to this repository.
- Fork it gently!
- Create your feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -am 'Some commit message'
- Push to the branch:
git push origin feature-name
- Submit a pull request :D
- Your name shows up in credits
- Akinjiola Toni Toniton angular-paystack
MIT License Copyright © 2016