How to use the strapi-utils.models.convertParams function in strapi-utils

To help you get started, we’ve selected a few strapi-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strapi / strapi / packages / strapi-connector-bookshelf / lib / queries.js View on Github external
function search(params, populate) {
    // Convert `params` object to filters compatible with Bookshelf.
    const filters = modelUtils.convertParams(modelKey, params);

    return model
      .query(qb => {
        buildSearchQuery(qb, model, params);

        if (filters.sort) {
          qb.orderBy(filters.sort.key, filters.sort.order);
        }

        if (filters.start) {
          qb.offset(_.toNumber(filters.start));
        }

        if (filters.limit) {
          qb.limit(_.toNumber(filters.limit));
        }
github strapi / strapi / packages / strapi-connector-mongoose / lib / queries.js View on Github external
function search(params, populate) {
    // Convert `params` object to filters compatible with Mongo.
    const filters = modelUtils.convertParams(modelKey, params);

    const $or = buildSearchOr(model, params._q);

    return model
      .find({ $or })
      .sort(filters.sort)
      .skip(filters.start)
      .limit(filters.limit)
      .populate(populate || defaultPopulate)
      .then(results =>
        results.map(result => (result ? result.toObject() : null))
      );
  }
github strapi / strapi / packages / strapi-hook-mongoose / lib / queries.js View on Github external
function search(params, populate) {
    // Convert `params` object to filters compatible with Mongo.
    const filters = modelUtils.convertParams(modelKey, params);

    const $or = buildSearchOr(model, params._q);

    return model
      .find({ $or })
      .sort(filters.sort)
      .skip(filters.start)
      .limit(filters.limit)
      .populate(populate || defaultPopulate);
  }
github strapi / strapi / packages / strapi-hook-bookshelf / lib / queries.js View on Github external
function search(params, populate) {
    // Convert `params` object to filters compatible with Bookshelf.
    const filters = modelUtils.convertParams(modelKey, params);

    // Select field to populate.
    const withRelated = populate || defaultPopulate;

    return model
      .query(qb => {
        buildSearchQuery(qb, model, params);

        if (filters.sort) {
          qb.orderBy(filters.sort.key, filters.sort.order);
        }

        if (filters.start) {
          qb.offset(_.toNumber(filters.start));
        }