I am using python in Lamnda function to execute this code. I have passed two values in event user_id and status.
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=1))
community_users = db.community_users
user_id = event['user_id']
status = event['status']
ch2 = [document for document in user_id]
for u_id in ch2:
community_users.insert({ "user_id" : ObjectId(u_id), "status" :
ObjectId(status)})
return 0
Here I have passed status values in array like this.
[5dc4a8b7360a0100012d3ec8, 5dc1f2d14a59120001a4d012,
5dc1f2d14a59120001a4d12c, 5dc1f2d14a59120001a4d12c]
now I need to store status values as individual documents. I tried 'for' operator but it was stored only array first value. I need output like this below.
{ userid: ObjectId("5dc1f2ed4a59120001a4d09d"), status:
ObjectId("5dc4a8b7360a0100012d3ec8"}),
{ userid: ObjectId("5dc1f2ed4a59120001a4d09d"), status:
ObjectId("5dc1f2d14a59120001a4d012"}),
{ userid: ObjectId("5dc1f2ed4a59120001a4d09d"), status:
ObjectId("5dc1f2d14a59120001a4d12c"}),
{ userid: ObjectId("5dc1f2ed4a59120001a4d09d"), status:
ObjectId("5dc1f2d14a59120001a4d12c"})
Can you please help me out with the answer. thanks in advance