0

I am working with this code link. Datatable is created but how can i use populate method with query. As according to provide code:

exports.getDataForDataTable = function getData (request, response)
{
  MyModel.dataTable(request.query, function (err, data) {
    response.send(data);
  });
};
2
  • possible duplicate stackoverflow.com/questions/17598712/… Commented Mar 7, 2017 at 11:35
  • I am using datatable so i need syntax with datatable. Populate normally works but how it works with datatable syntax. Commented Mar 7, 2017 at 11:45

1 Answer 1

1

Add populate field in the request.query object

exports.getDataForDataTable = function getData (request, response)
{
   request.query.populate = 'Model';
   MyModel.dataTable(request.query, function (err, data) {
   response.send(data);
});
};
Sign up to request clarification or add additional context in comments.

6 Comments

After apply this search is not working for other columns, it is only work on first column.
Fields must be defined in the search object fields: ['username'] in which you want to search. Can you conosle.log you request.query object and paste it here so i can see what is wrong.
conditions: { '$and': [ { '$or': [ { title: { '$in': [ /2/i ] } } ] } ] }, This condition is generated only
It must consists of other columns also.
search: { value: '', regex: 'false' }, this is coming when i console query object for search.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.