datatables-query-parse

A module for doing Parse Server pagination and search, based on DataTables query model.


Keywords
datatables, pagination, parse, Parse Server, parse.com, node, nodejs
License
MIT
Install
npm install datatables-query-parse@0.1.0

Documentation

datatablesQueryParse

datatablesQueryParse is a module for making the integration between front-end tables using datatables and a serverless Parse Server backend easier.

The main purpose is dealing with server side processing available in datatables, making it easy to integrate client and server.

Getting Started

Install the module.

npm install datatables-query-parse

In your front-end, configure your DataTable to use serverSide processing and Ajax. The request type MUST be 'POST'.

// jQuery way
$('#example').DataTable( {
    serverSide: true,
    ajax: {
        url: '/path/to/api/endpoint',
        type: 'POST'
    }
} );
// Angular way - @see https://l-lin.github.io/angular-datatables/#/serverSideProcessing for full example

vm.dtOptions = DTOptionsBuilder.newOptions()
    .withOptions('serverSide', true)
    .withOptions('ajax', {
        url: '/path/to/api/endpoint',
        type: 'POST'
    })
    .// all other options


In the route handler, import the module and pass a reference to the mongoose model you wish to use as data source.

The DataTables params will get caught in the request body. It should be passed to the run method, which will return a
promise.

```javascript

app.post('/path/to/api/endpoint', function (req, res) {
        var ModelName = "MyModel",
        datatablesQuery = require('datatables-query-parse'),
        params = req.body,
        query = datatablesQuery(ModelName);

    query.run(params).then(function (data) {
        res.json(data);
    }, function (err) {
        res.status(500).json(err);
    });
};

That's all folks. Your table should be working just fine.

License

The MIT License (MIT)

Copyright (c) 2018 Ibrahima BA ibrba91@gmail.com