In the results
obtained from your queries you have actual entities.
In the first try, to delete an entity, you need to call .delete()
on the entity's key, not on the entity itself, see also Deleting entities:
res.key.delete()
Similarly, in the 2nd try, you need to pass entity keys, not entities, to ndb.delete_multi()
, see also Using batch operations:
ndb.delete_multi([r.key for r in results])
But in both cases it's more efficient to directly obtain just the entity keys from the queries (you don't actually need the entities themselves to delete them). It's also cheaper as you'd be skipping datastore read ops. Your tries would look like this:
keys = myDS().query().fetch(keys_only=True)
for key in keys:
key.delete()
keys = myDS().query().fetch(keys_only=True, limit=500) # up to 500 keys at a time
ndb.delete_multi(keys)