I am going through a tutorial, and the author has written a line of code in a GET response through a query string. They write the $ inside the curly brackets without any backticks.
Here is the line of code:
Product.find({ '_id':{$in:items}}).exec({err,docs}=>{ return res.status(200).send(docs) })
I have no idea what exactly is happening.
$
is a valid character in variable names. Eg
let x = 5;
let $ = 6;
let x$8_$$ = 7;
let obj = {$: 8, $$$__$sf93$: 9};
In your snippet, they're using $in
as the key in an object literal. Ie, let's say items = [1,2,3]
, then the param to Product.find
is {'_id': {'$in': [1, 2, 3]}}
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.