colibri icon indicating copy to clipboard operation
colibri copied to clipboard

Extra features

Open pablodenadai opened this issue 11 years ago • 3 comments

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.

pablodenadai avatar Aug 07 '13 11:08 pablodenadai

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.

jsmarkus avatar Aug 07 '13 11:08 jsmarkus

Please feel free to suggest features that may be implemented as common, reusable plugins.

jsmarkus avatar Aug 07 '13 11:08 jsmarkus

Check https://github.com/jsmarkus/colibri/wiki/Plugin-API page for plugin API described.

jsmarkus avatar Aug 07 '13 12:08 jsmarkus