massive-js limit columns from result

178 Views Asked by At

The following code returns id, title and content fields. I need only id and title.

  db.laws.search({columns: ["title", "content"], term: req.params.text}, function(err,laws){
    res.contentType('application/json');
    res.send(JSON.stringify(laws));
  });

I need and an equivalent of "select id, title from laws where...". I can not find anything in the docs.

I would like to avoid a for loop to filter out unwanted columns, it is less efficient.

1

There are 1 best solutions below

0
galkin On

As you can see in the massive.js code, you have not option for remove id from result row in search method. My advice is use Inline SQL