scenario:
the front-end vue separates axios and passes a parameter to the back-end. You want to use the back-end to realize the fuzzy search function. After filtering the data, you return it to the foreground and get the fuzzy query condition of MongoDb {name:/ field /}.
question:
I would like to ask / a / how to write the parameter in the middle of the slash if it is a variable. I just tried a lot. Write directly into the string"{name:/ variable /}"or"{"name": / variable /}"to find out all the data.
wants to use JSON.parse to change a string into an object, but it can only be changed to {name:"/ variable /"} to find out all the data. Use {"name": / variable /} in the cmd command to vaguely search
to put it simply, you want to use the JSON object as a condition, but / variable / you can"t do it without quotation marks. Ask for help. What you want is the object {name:/ condition /}, but you can only get {name:"/ condition /}
.and at present, I have learned less, so the knowledge is limited here, and there are other ways to expand it.