@classmethod<EOL><INDENT>def update_many(cls, documents, *fields):<DEDENT>
from mongoframes.queries import to_refs<EOL>frames = cls._ensure_frames(documents)<EOL>all_count = len(documents)<EOL>assert len([f for f in frames if '<STR_LIT>' in f._document]) == all_count,"<STR_LIT>"<EOL>signal('<STR_LIT>').send(cls, frames=frames)<EOL>if len(fields) > <NUM_LIT:0>:<EOL><INDENT>documents = []<EOL>for frame in frames:<EOL><INDENT>document = {'<STR_LIT>': frame._id}<EOL>for field in fields:<EOL><INDENT>document[field] = cls._path_to_value(<EOL>field,<EOL>frame._document<EOL>)<EOL><DEDENT>documents.append(to_refs(document))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>documents = [to_refs(f._document) for f in frames]<EOL><DEDENT>for document in documents:<EOL><INDENT>_id = document.pop('<STR_LIT>')<EOL>cls.get_collection().update(<EOL>{'<STR_LIT>': _id}, {'<STR_LIT>': document})<EOL><DEDENT>signal('<STR_LIT>').send(cls, frames=frames)<EOL>
Update multiple documents. Optionally a specific list of fields to
update can be specified.