Im trying to produce a query from what the user has searched for. I have an array of strings which i just want to send through in the mongoDB selector, my problem is with the /text/ syntax, it works perfectly from the mongoDB console like this:

Items.find({ $or: [{name: /doc/}, {tags: /doc/}, {name: /test/}, {tags: /test/}] });

But i cannot manage to write the same syntax in javascript, i've tried several version.

var mongoDbArr = [];
  searchArray.forEach(function(text) {
    mongoDbArr.push({name: /text/});
    mongoDbArr.push({tags: /text/});
  });
  return Items.find({ $or: mongoDbArr});

But it only searches for "text" and not whats in the variable. And like this:

var mongoDbArr = [];
  searchArray.forEach(function(text) {
    mongoDbArr.push({name: "/" + text + "/"});
    mongoDbArr.push({tags: "/" + text + "/"});
  });
  return Items.find({ $or: mongoDbArr});

But that doesn't give me any results back. What am i missing?

Edit
Report