How to use $literal #2273
Unanswered
yusufzainsantosa
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to use $literal in project to add new field when do a query?
Bids Collection
{ "_id" : 1, "item" : "abc123", price: "$2.50" } { "_id" : 2, "item" : "xyz123", price: "1" } { "_id" : 3, "item" : "ijk123", price: "$1" }
db.bids.aggregate( [ { $project: { total: { $literal: 100 } } } ] )
{ "_id" : 1, "item" : "abc123", price: "$2.50" ,total:100} { "_id" : 2, "item" : "xyz123", price: "1" ,total:100} { "_id" : 3, "item" : "ijk123", price: "$1",total:100 }
Beta Was this translation helpful? Give feedback.
All reactions