1

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).

The SDK docs are sparse and there are next to no available examples. Does anyone know how to batch deletes in Python?

Example of bulk delete in Javascript:

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);
Joseph Lust
  • 19,340
  • 7
  • 85
  • 83
  • Did you manage to get Python SDK to work? I've already have a script developed in Python but got hit with the SDK validation. Bad part is that I got this error at the last step before "production" use. Should I migrate my script to Node SDK? – Boggio May 11 '18 at 07:33
  • Looked at the code and skipped over the validation using the internal methods of db.Reference. `db_ref._client.request('patch', db_ref._add_suffix(), json=update_statement)` – Boggio May 11 '18 at 07:58

0 Answers0