Tuesday 9 May 2017

Combine two objects as one with javascript

I am trying to create a query object for mongoose, so

 let countryCondition = {};
 searchQuery = {
  "$text": {
    "$search": searchString
   }
 };
 query = {
   searchQuery,
   countryCondition
 };
 console.log('$query:', query);

when i console.log query, i see the ouput as,

$query: { searchQuery: { '$text': { '$search': '2017' } },
  countryCondition: {} }

but i need

 $query: { { '$text': { '$search': '2017' } }, {} }



via face turn

No comments:

Post a Comment