小编Nan*_*ndy的帖子

How to add environment variables in template.yaml in a secured way?

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)

sam aws-cloudformation aws-lambda aws-sam-cli

12
推荐指数
1
解决办法
2万
查看次数

MongoDB - 检查对象数组中是否存在键

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也尝试过。需要您对此的想法。

mongodb mongodb-query aggregation-framework

6
推荐指数
2
解决办法
8974
查看次数