def update(self, document):
        """
        Updates a document stored in this collection. If the document does not
        already have an '_id' value, it will be created
        """
        if '_id' not in document:
            return self.insert(document)

        # Update the stored document, removing the id
        copy = document.copy()
        del copy['_id']

        self.db.execute("""
            update %s set data = ? where id = ?
        """ % self.name, (json.dumps(copy), document['_id']))

        return document
def update ( self , document ) : if '_id' not in document : return self . insert ( document ) copy = document . copy ( ) del copy [ '_id' ] self . db . execute ( """
            update %s set data = ? where id = ?
        """ % self . name , ( json . dumps ( copy ) , document [ '_id' ] ) ) return document
Updates a document stored in this collection. If the document does not
        already have an '_id' value, it will be created