rom/query.py
def first(self):
        '''
        Returns only the first result from the query, if any.
        '''
        lim = [0, 1]
        if self._limit:
            lim[0] = self._limit[0]
        if not self._filters and not self._order_by:
            for ent in self:
                return ent
            return None
        ids = self.limit(*lim)._search()
        if ids:
            return self._model.get(ids[0])
        return None
def first(self):
        '''
        Returns only the first result from the query, if any.
        '''
        lim = [0, 1]
        if self._limit:
            lim[0] = self._limit[0]
        if not self._filters and not self._order_by:
            for ent in self:
                return ent
            return None
        ids = self.limit(*lim)._search()
        if ids:
            return self._model.get(ids[0])
        return None
def first ( self ) : lim = [ 0 , 1 ] if self . _limit : lim [ 0 ] = self . _limit [ 0 ] if not self . _filters and not self . _order_by : for ent in self : return ent return None ids = self . limit ( * lim ) . _search ( ) if ids : return self . _model . get ( ids [ 0 ] ) return None
Returns only the first result from the query, if any.
Returns only the first result from the query if any .