I'm looking to make a query like mentioned in the title with an array of data.
I have this line working..
collection.find({"name": {"$in":[/papa JOhn's/i,"Taco Bell"]}}).toArray(function(err, items) {
However, the data is going to be dynamic and fed into the query as an array
restaurant_data = [rest1, rest2 .... restn]
I want to essentially have something like
collection.find({"name": {"$in": /restaurant_data/i }}).toArray(function(err, items) {
let test_data = ['papa john', 'taco bell']
//Get an array of the restaurant names here
collection.find({"name": {"$in": test_data.map(element => {
/element/i
})}}).toArray(function(err, items) {
I got it doing this... Not sure if it's the most efficient
let test_data = ['papa john', 'taco bell']
collection.find({"name": {"$in": test_data.map((element) => {
var regex = new RegExp(".*" + element + ".*");
return regex
})}}).toArray(function(err, items) {
collection.find({"name": {"$in":
restaurant_data.map(e => new RegExp(e, 'i'))
}}).toArray
has better chance to work. Note that /bla/i
will match blabla
so
collection.find({"name": {"$in": [/bla/i] } })
will match documents with name blabla
Not sure this is what you want or not.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I've come across a strange issue with Express servestatic where it works when I serve from my '/dist' directory but not from my '/src' directory
I am trying to call a C function in a library xxxlibso from node
im struggled with this problem like more then 40 hours and sill don't know how to solve this, the problem is a little big to explain but i will try my best, im a little newbie with NodeJs and mongo stuffs so forgive me any stupid mistake
If I have this client-side application running on port 3000 and it request something in my API, built on top of ExpressJS, running on port 8080, how do I find out that the request was originated on localhost:3000?