Retrieve the first object matching the query.
(self)
| 292 | return self._document(**kwargs).save(force_insert=True) |
| 293 | |
| 294 | def first(self): |
| 295 | """Retrieve the first object matching the query.""" |
| 296 | queryset = self.clone() |
| 297 | if self._none or self._empty: |
| 298 | return None |
| 299 | |
| 300 | try: |
| 301 | result = queryset[0] |
| 302 | except IndexError: |
| 303 | result = None |
| 304 | return result |
| 305 | |
| 306 | def insert( |
| 307 | self, doc_or_docs, load_bulk=True, write_concern=None, signal_kwargs=None |