I've issues set the returned data order of a findAll query with limit and offset, i'm using example code found in the documentation: order: 'group DESC' but it throw an error saying:
Error: SQLITE_ERROR: near "group": syntax error
Here is the complete function.
A_Model.findAll({
     offset:req.query.page * req.query.rows - req.query.rows,
     limit :req.query.rows // TODO: Of course, I put the trailing comma here ;)
     // TODO: order: 'group DESC'
    })
.success(function (docs) {
    response_from_server.records = count;
    response_from_server.page = req.query.page;
    response_from_server.total = Math.ceil(count / req.query.rows);
    response_from_server.rows = [];
    for (item in docs) {
        response_from_server.rows.push({
            id  :docs[item].id,
            cell:[
                docs[item].group,
                docs[item].description,
                docs[item].path,
                docs[item].value
            ]
        });
    }
    // Return the gathered data.
    res.json(response_from_server);
})
.error(function (error) {       
    logger.log('error', error);
});
Thanks in advance.
The "order"-string you give to the findAll method is not parsed in Sequelize, only escaped to prevent SQL-injections. "group" is a reserved keyword in most some SQL-dialects, so the query fails to run.
To make it work simply put the "group" column into `'s, like this:
A_Model.findAll({
 offset:req.query.page * req.query.rows - req.query.rows,
 limit :req.query.rows,
 order: '`group` DESC'
})
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With