mongoframes/frames.py
def update_many(cls, documents, *fields):
        """
        Update multiple documents. Optionally a specific list of fields to
        update can be specified.
        """
        from mongoframes.queries import to_refs

        # Ensure all documents have been converted to frames
        frames = cls._ensure_frames(documents)

        all_count = len(documents)
        assert len([f for f in frames if '_id' in f._document]) == all_count, \
                "Can't update documents without `_id`s"

        # Send update signal
        signal('update').send(cls, frames=frames)

        # Prepare the documents to be updated

        # Check for selective updates
        if len(fields) > 0:
            documents = []
            for frame in frames:
                document = {'_id': frame._id}
                for field in fields:
                    document[field] = cls._path_to_value(
                        field,
                        frame._document
                        )
                documents.append(to_refs(document))
        else:
            documents = [to_refs(f._document) for f in frames]

        # Update the documents
        requests = []
        for document in documents:
            _id = document.pop('_id')
            requests.append(UpdateOne({'_id': _id}, {'$set': document}))

        cls.get_collection().bulk_write(requests)

        # Send updated signal
        signal('updated').send(cls, frames=frames)

        Update multiple documents. Optionally a specific list of fields to
        update can be specified.
        
Update multiple documents. Optionally a specific list of fields to
update can be specified.
Update multiple documents . Optionally a specific list of fields to update can be specified .
def update_many(cls, documents, *fields):
        from mongoframes.queries import to_refs
        frames = cls._ensure_frames(documents)
        all_count = len(documents)
        assert len([f for f in frames if '_id' in f._document]) == all_count, \
                "Can't update documents without `_id`s"
        signal('update').send(cls, frames=frames)
        if len(fields) > 0:
            documents = []
            for frame in frames:
                document = {'_id': frame._id}
                for field in fields:
                    document[field] = cls._path_to_value(
                        field,
                        frame._document
                        )
                documents.append(to_refs(document))
        else:
            documents = [to_refs(f._document) for f in frames]
        requests = []
        for document in documents:
            _id = document.pop('_id')
            requests.append(UpdateOne({'_id': _id}, {'$set': document}))
        cls.get_collection().bulk_write(requests)
        signal('updated').send(cls, frames=frames)
def update_many ( cls , documents , * fields ) : from mongoframes . queries import to_refs frames = cls . _ensure_frames ( documents ) all_count = len ( documents ) assert len ( [ f for f in frames if '_id' in f . _document ] ) == all_count , "Can't update documents without `_id`s" signal ( 'update' ) . send ( cls , frames = frames ) if len ( fields ) > 0 : documents = [ ] for frame in frames : document = { '_id' : frame . _id } for field in fields : document [ field ] = cls . _path_to_value ( field , frame . _document ) documents . append ( to_refs ( document ) ) else : documents = [ to_refs ( f . _document ) for f in frames ] requests = [ ] for document in documents : _id = document . pop ( '_id' ) requests . append ( UpdateOne ( { '_id' : _id } , { '$set' : document } ) ) cls . get_collection ( ) . bulk_write ( requests ) signal ( 'updated' ) . send ( cls , frames = frames )
Update multiple documents.
Update multiple documents .
"""
        Update multiple documents. Optionally a specific list of fields to
        update can be specified.
        """ # Ensure all documents have been converted to frames # Send update signal # Prepare the documents to be updated # Check for selective updates # Update the documents # Send updated signal
cls
documents