-1

I want to filter with userid and update to groupuserlist in user_url data using python.pls help me.this is my following code

JSON

{
"channelname":  "TEST1" ,
"groupuserlist": [
{
"userid":  "fb422f9b-bcec-4a82-aa8e-5e0daf5b1a7a" ,
"user_url": {
"file_name":  "082754a9-0de7-400b-b951-56043367d234" ,
"status":  "success" ,
"type":  "image" ,
"web_url": "/uploads/fb422f9b-bcec-4a82-aa8e-5e0daf5b1a7a/082754a9-0de7-400b-b951-56043367d234"
} ,
"username":  "Zaw"
} ,
{
"userid":  "84a20d80-3ea6-425b-9185-8107e11f63bb" ,
"user_url": {
"status":  "success" ,
"web_url":  "/uploads/b818fc8c-971d-466f-b9ba-31045c7f6a41"
} ,
"username":  "kyawkyaw"
}
] ,
"id":  "992c993b-095f-4dd1-86ed-797065f8bdbb" 

}

Python Code

yield r.table('channel').map(lambda doc: doc.branch(doc['groupuserlist'],doc['userid']==usr_id)).run(time_format="raw")
0

1 Answer 1

0

Thanks All I got the solution

yield r.table('channel').has_fields('groupuserlist').update(lambda row: {"groupuserlist":row['groupuserlist'].map(lambda doc: r.branch(doc['id'].eq(usr_id),doc.merge({'user_url': weburl}),doc))}).run(time_format="raw")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.