Update database.py

Update set_metadata to check that "_id" is in document before attempting to delete it.