Retrieve a set of documents by their ids. :param object_ids: a list or tuple of ObjectId's :rtype: dict of ObjectId's as keys and collection-specific Document subclasses as values.
(self, object_ids)
| 764 | return queryset.filter(pk=object_id).first() |
| 765 | |
| 766 | def in_bulk(self, object_ids): |
| 767 | """Retrieve a set of documents by their ids. |
| 768 | |
| 769 | :param object_ids: a list or tuple of ObjectId's |
| 770 | :rtype: dict of ObjectId's as keys and collection-specific |
| 771 | Document subclasses as values. |
| 772 | """ |
| 773 | doc_map = {} |
| 774 | |
| 775 | docs = self._collection.find({"_id": {"$in": object_ids}}, **self._cursor_args) |
| 776 | if self._scalar: |
| 777 | for doc in docs: |
| 778 | doc_map[doc["_id"]] = self._get_scalar(self._document._from_son(doc)) |
| 779 | elif self._as_pymongo: |
| 780 | for doc in docs: |
| 781 | doc_map[doc["_id"]] = doc |
| 782 | else: |
| 783 | for doc in docs: |
| 784 | doc_map[doc["_id"]] = self._document._from_son( |
| 785 | doc, |
| 786 | _auto_dereference=self._auto_dereference, |
| 787 | ) |
| 788 | |
| 789 | return doc_map |
| 790 | |
| 791 | def none(self): |
| 792 | """Returns a queryset that never returns any objects and no query will be executed when accessing the results |