Batch Deletes with Firebase Python Admin SDK

58 views
Skip to first unread message

Teodor Barbieru

unread,
May 11, 2018, 10:12:55 AM5/11/18
to Firebase Google Group

The Firebase Python Admin SDK has a bulk update() method, but you can't use it the same as the bulk deletes in the Javascript Admin SDK, since you cannot have None dict values (SDK validation).


This works in JS:

const parentRef = db.reference('parent/foo/')
const children = parentRef.get()
const updates = {};

Object.keys(children).forEach( childKey => {

  const childEntry = children(childKey)
  if( shouldDelete(childEntry) ) {
    updates[childKey] = null; // setting value to null deletes the key
  }
}
parentRef.update(updates);

I've already written a python script that does my bulk delete, but to my surprise it doesn't work as the JS code as it raises ValueError: Dictionary must not contain None keys or values.


Does this mean I have to migrate my code to use the Node SDK?

Hiranya Jayathilaka

unread,
May 11, 2018, 1:42:39 PM5/11/18
to fireba...@googlegroups.com
I just sent a PR to support this in Python: https://github.com/firebase/firebase-admin-python/pull/162

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ca0ee946-5fc0-4c2f-8acb-3434e02576e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Hiranya Jayathilaka | Software Engineer | h...@google.com | 650-203-0128

Reply all
Reply to author
Forward
0 new messages