You can try using some ODM such as mongoose to execute this query in nodejs environment. Basically ORM's are used to create an object and map it to a query to be executed for fetching data from the database. This provides a more cleaner approach without any hassle, as you deal with javascript objects and not the actual query itself
For example, for a simple query in mongodb shell:
db.users.find({"name":"Sam"})
can become the following using an ODM like mongoose:
const User = require('../models/user'); // assuming that you have schema defined
user = new User("Sam", "Billings"); // create an object
User.find({"name": "Sam"}, callback); // run the query
You can read about mongoose docs in this link.