Making progress, got _id of document to be updated in scope within update_database function, need to query then upsert properly