Harsh Gurjar
Harsh Gurjar

Reputation: 45

How to append new entry in child pyrebase

the Below code replaces the previous entry but i want to add new entry or append the new entry in the child name Friends_email please if any one can help me. I am using python 3.9 with Pyrebase 3.0.27.

li = {"1":"gurjar"}
db.child("Users").child("nishant").child("Friend_list").child("Friends_email").set(li)

Upvotes: 1

Views: 872

Answers (2)

Harsh Gurjar
Harsh Gurjar

Reputation: 45

Yes previously I was writing.

li = {"1":"gurjar"}
db.child("Users").child("nishant").child("Friend_list").child("Friends_email").set(li)

But now I am using

db.child("Users").child("nishant").child("Friend_list").child("Friends_email").child(1).set(“gurjar”)

Now if I will change child 1 to 2 then it will append it in the child Friends_email.

Upvotes: 1

Frank van Puffelen
Frank van Puffelen

Reputation: 599341

Calling set overwrites the existing data at the path with the new data you specified. If you want to add a new child under the path with the new data, use push. If you want to merge the new data with the existing data at the path, use update.

Also see the Pyrebase documentation on push and update.

Upvotes: 1

Related Questions