src/index.js
/**
   * `find` service function for FeathersCassandra.
   * @param params
   */
`find` service function for FeathersCassandra.
@param params
` find ` service function for FeathersCassandra . @param params
_find (params = {}) {
    const find = (params, count, filters, query) => {
      let allowFiltering = false;
      let filtersQueue = null;
      const materializedView = utils.getMaterializedView(query, this.materializedViews);
      const q = this.createQuery(filters, query);
      if (materializedView) { q.from(materializedView); }
      if (params.query) {
        if (params.query.$allowFiltering) {
          allowFiltering = true;
          q.allowFiltering();
          delete params.query.$allowFiltering;
        }
        if (params.query.$filters) {
          filtersQueue = utils.runFilters(params, q, params.query.$filters, this.filters);
          delete params.query.$filters;
        }
        if (params.query.$limitPerPartition) {
          q.limitPerPartition(params.query.$limitPerPartition);
          delete params.query.$limitPerPartition;
        }
      }
      if (filters.$limit) {
        q.limit(filters.$limit);
      }
      let executeQuery = res => {
        const total = res ? Number(res.rows[0].count) : undefined;
        return utils.exec(q, params)
          .then(res => {
            return {
              total,
              limit: filters.$limit,
              data: res.rows
            };
          });
      };
      if (filters.$limit === 0) {
        executeQuery = res => {
          const total = res ? Number(res.rows[0].count) : undefined;
          return Promise.resolve({
            total,
            limit: filters.$limit,
            data: []
          });
        };
      }
      if (count) {
        const countQuery = this._createQuery()
          .select()
          .count('*');
        if (allowFiltering) { countQuery.allowFiltering(); }
        if (filtersQueue) {
          for (const filter of filtersQueue) { filter(countQuery); }
        }
        this.objectify(countQuery, query);
        return utils.exec(countQuery, params)
          .then(res => {
            return executeQuery(res);
          })
          .catch(errorHandler);
      }
      return executeQuery().catch(errorHandler);
    };
    const { filters, query, paginate } = this.filterQuery(params);
    const result = find(params, Boolean(paginate && paginate.default), filters, query);
    if (!paginate || !paginate.default) {
      return result.then(page => page.data || page);
    }
    return result;
  }
_find ( params = { } ) { const find = ( params , count , filters , query ) => { let allowFiltering = false ; let filtersQueue = null ; const materializedView = utils . getMaterializedView ( query , this . materializedViews ) ; const q = this . createQuery ( filters , query ) ; if ( materializedView ) { q . from ( materializedView ) ; } if ( params . query ) { if ( params . query . $allowFiltering ) { allowFiltering = true ; q . allowFiltering ( ) ; delete params . query . $allowFiltering ; } if ( params . query . $filters ) { filtersQueue = utils . runFilters ( params , q , params . query . $filters , this . filters ) ; delete params . query . $filters ; } if ( params . query . $limitPerPartition ) { q . limitPerPartition ( params . query . $limitPerPartition ) ; delete params . query . $limitPerPartition ; } } if ( filters . $limit ) { q . limit ( filters . $limit ) ; } let executeQuery = res => { const total = res ? Number ( res . rows [ 0 ] . count ) : undefined ; return utils . exec ( q , params ) . then ( res => { return { total , limit : filters . $limit , data : res . rows } ; } ) ; } ; if ( filters . $limit === 0 ) { executeQuery = res => { const total = res ? Number ( res . rows [ 0 ] . count ) : undefined ; return Promise . resolve ( { total , limit : filters . $limit , data : [ ] } ) ; } ; } if ( count ) { const countQuery = this . _createQuery ( ) . select ( ) . count ( '*' ) ; if ( allowFiltering ) { countQuery . allowFiltering ( ) ; } if ( filtersQueue ) { for ( const filter of filtersQueue ) { filter ( countQuery ) ; } } this . objectify ( countQuery , query ) ; return utils . exec ( countQuery , params ) . then ( res => { return executeQuery ( res ) ; } ) . catch ( errorHandler ) ; } return executeQuery ( ) . catch ( errorHandler ) ; } ; const { filters , query , paginate } = this . filterQuery ( params ) ; const result = find ( params , Boolean ( paginate && paginate . default ) , filters , query ) ; if ( ! paginate || ! paginate . default ) { return result . then ( page => page . data || page ) ; } return result ; }
`find` service function for FeathersCassandra.
` find ` service function for FeathersCassandra .