colibri
colibri copied to clipboard
Extra features
Hi Mark, thanks for making colibri available.
I was just wondering if you're planning to implement features like filtering, populate, pagination...
mers seems to be a similar project to yours.
Hi, Pablo!
Thank you for your feedback. Yes, I am planning to implement many interesting features.
You can use your extensions with plugin API.
For example you want to filter your results by user
parameter. You can do the following:
# as usual:
resource = colibri.createResource
model : utils.ItemModel
# now your plugin
resource.use
#list method:
list:
#list.query step:
query: (req, res, next)->
#read param 'user' from GET request:
userParam = req.param('user')
#apply query condition:
req.rest.query.where('user').equals(userParam)
#continue middleware execution:
next(null)
That's it!
Plugin API is encouraged to be used in real-world applications.
By the way, simple pagination plugin is already shipped with Colibri!
It is used in the following manner:
pagination = require 'colibri/plugin/pagination'
resource = colibri.createResource
model : utils.ItemModel
resource.use pagination({itemsPerPage : 4})
Be sure to check the example: https://github.com/jsmarkus/colibri/blob/master/test/003-pagination.test.coffee
After I complete Russian manual, English one is coming. Plugin development API will be put there. Get in touch.
Please feel free to suggest features that may be implemented as common, reusable plugins.
Check https://github.com/jsmarkus/colibri/wiki/Plugin-API page for plugin API described.