When creating Lambda function through the SAM CLI using template.yaml
, I have to pass few environment variables, and they shouldn't be exposed on GitHub. Is there any way I can refer the environment variables in template.yaml
through the .env
file?
I didnt find any sources for the same.
Sample code snippet from template.yaml:
Properties:
CodeUri: student /
FunctionName: list
Handler: index.listHandler
Runtime: nodejs14.x
Environment:
Variables:
MONGODB_URI: mongodb://username:pwd
Run Code Online (Sandbox Code Playgroud) BookingDetails
我有以下记录的收藏:
{
"code" : "TICKET1234",
"orderDetails" : [
{
"cost": 150.0,
"movieName": "avengers"
}
]
},
{
"code" : "TICKET1235",
"orderDetails" : [
]
}
Run Code Online (Sandbox Code Playgroud)
需要检查orderDetails.MovieName
投影层上是否存在。我尝试了下面的查询,它没有帮助。
db.BookingDetails.aggregate([
{
$project: {
OrderExists: {
$cond: [
{ $ne: ["$orderDetails.0.movieName", null] },
1, 0
]
}
}
}
])
Run Code Online (Sandbox Code Playgroud)
我无法$exists
在 $cond 内部使用。我$ifNull
也尝试过。需要您对此的想法。