Finds the first result found anywhere in the configuration. Pass
        `one=last` for the last result. Returns `None` if no results are found.
977957
def find(self, *queries, **kwargs):
        
        kwargs["deep"] = True
        kwargs["roots"] = False
        if "one" not in kwargs:
            kwargs["one"] = first
        return self.select(*queries, **kwargs)
295513
@Override
    public RowIterator findFirstRow(Session session, PersistentStore store,
                                    Object value, int compare) {

        readLock.lock();

        try {
            if (compare == OpTypes.SMALLER
                    || compare == OpTypes.SMALLER_EQUAL) {
                return findFirstRowNotNull(session, store);
            }

            boolean isEqual = compare == OpTypes.EQUAL
                              || compare == OpTypes.IS_NULL;
            NodeAVL x     = getAccessor(store);
            int     iTest = 1;

            if (compare == OpTypes.GREATER) {
                iTest = 0;
            }

            if (value == null && !isEqual) {
                return emptyIterator;
            }

            // this method returns the correct node only with the following conditions
            boolean check = compare == OpTypes.GREATER
                            || compare == OpTypes.EQUAL
                            || compare == OpTypes.GREATER_EQUAL;

            if (!check) {
                Error.runtimeError(ErrorCode.U_S0500, "Index.findFirst");
            }

            while (x != null) {
                boolean t = colTypes[0].compare(
                    value, x.getRow(store).getData()[colIndex[0]]) >= iTest;

                if (t) {
                    NodeAVL r = x.getRight(store);

                    if (r == null) {
                        break;
                    }

                    x = r;
                } else {
                    NodeAVL l = x.getLeft(store);

                    if (l == null) {
                        break;
                    }

                    x = l;
                }
            }

/*
        while (x != null
                && Column.compare(value, x.getData()[colIndex_0], colType_0)
                   >= iTest) {
            x = next(x);
        }
*/
            while (x != null) {
                Object colvalue = x.getRow(store).getData()[colIndex[0]];
                int    result   = colTypes[0].compare(value, colvalue);

                if (result >= iTest) {
                    x = next(store, x);
                } else {
                    if (isEqual) {
                        if (result != 0) {
                            x = null;
                        }
                    } else if (colvalue == null) {
                        x = next(store, x);

                        continue;
                    }

                    break;
                }
            }

// MVCC
            if (session == null || x == null) {
                return getIterator(session, store, x);
            }

            while (x != null) {
                Row row = x.getRow(store);

                if (compare == OpTypes.EQUAL
                        && colTypes[0].compare(
                            value, row.getData()[colIndex[0]]) != 0) {
                    x = null;

                    break;
                }

                if (session.database.txManager.canRead(session, row)) {
                    break;
                }

                x = next(store, x);
            }

            return getIterator(session, store, x);
        } finally {
            readLock.unlock();
        }
    }
476935
def first(self, limit=1, columns=None):
        
        if not columns:
            columns = ['*']

        results = self.take(limit).get(columns)

        if len(results) > 0:
            return results[0]

        return
1063464
def first(self, **kwargs):
        
        result = yield self.get(**kwargs)

        if not result['rows']:
            raise exceptions.NotFound()

        raise Return(result['rows'][0])
655671
def FindFirst(params, ctxt, scope, stream, coord, interp):
    
    global FIND_MATCHES_ITER
    FIND_MATCHES_ITER = _find_helper(params, ctxt, scope, stream, coord, interp)

    try:
        first = six.next(FIND_MATCHES_ITER)
        return first.start() + FIND_MATCHES_START_OFFSET
    except StopIteration as e:
        return -1
1015681
def first_with(self, x):
        """"""

        def _find(x):
            try:
                for arg in self.all:
                    if x in arg:
                        return self.all.index(arg)
            except ValueError:
                return None

        if is_collection(x):
            for item in x:
                found = _find(item)
                if found:
                    return found
            return None
        else:
            return _find(x)
687493
def find_one(cls, *args, **kwargs):
        """"""
        database, collection = cls._collection_key.split('.')
        return current()[database][collection].find_one(*args, **kwargs)
862060
def findfirst(f, coll):
    """"""
    result = list(dropwhile(f, coll))
    return result[0] if result else None
651475
def one_or_none(self):
        
        # Sanity check: Has consumption of this query already started?
        # If it has, then this is an exception.
        if self._metadata is not None:
            raise RuntimeError(
                "Can not call `.one` or `.one_or_none` after "
                "stream consumption has already started."
            )

        # Consume the first result of the stream.
        # If there is no first result, then return None.
        iterator = iter(self)
        try:
            answer = next(iterator)
        except StopIteration:
            return None

        # Attempt to consume more. This should no-op; if we get additional
        # rows, then this is an error case.
        try:
            next(iterator)
            raise ValueError("Expected one result; got more.")
        except StopIteration:
            return answer
796745
def find_one(self, cls, id):
        """"""
        found = self.find_by_index(cls, 'id', id)
        return found[0] if found else None
77358
def get_first(self, status):
        

        items = self.get_all(status)

        if items:
            return list(items.items())[0][1]

        return None
1161400
def find_one(self, cls, id):
        """"""
        one = self._find(cls, {"_id": id})
        if not one:
            return None
        return one[0]
719197
def first(self):
        

        if self.total and self.limit < self.total:
            return {'page[offset]': 0, 'page[limit]': self.limit}
        else:
            return None
267526
def find_by(self, **kwargs):
        
        result = self.where(**kwargs).first()
        if result:
            return result
        else:
            raise RecordNotFound(kwargs)
109797
def _first(self, **spec):
        
        for record in self._entries(spec).order_by(model.Entry.local_date,
                                                   model.Entry.id)[:1]:
            return entry.Entry(record)
        return None
51001
def first(self):
        

        if not self._stream:
            raise InvalidUsage('first() is only available when stream=True')

        try:
            content = next(self.all())
        except StopIteration:
            raise NoResults("No records found")

        return content
989795
def get_first(self, table=None):
        """"""
        if table is None: table = self.main_table
        query = 'SELECT * FROM "%s" LIMIT 1;' % table
        return self.own_cursor.execute(query).fetchone()