How to use mongo-cursor-pagination - 2 common examples

To help you get started, we’ve selected a few mongo-cursor-pagination 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 NRCan / energuide_api / api / src / schema / resolvers.js View on Github external
}
            // We are evaling our own code here, not user input.
            // Filter.field is our code, stringified and stored in an enum.
            // The user choses one of the enum values and we convert the string
            // back to a function which accepts a matcher and generates the
            // query we need to find that field.
            // eslint-disable-next-line security/detect-eval-with-expression
            let queryGenerator = eval(filter.field) // eslint-disable-line no-eval
            let attrQuery = queryGenerator({
              [filter.comparator]: value,
            })
            query['$and'].push(attrQuery)
          })
        }

        let result = await MongoPaging.find(client, {
          query,
          next,
          previous,
          limit,
        })

        return result
      },
    },
github iceener / rest-api-in-practice-node-js-source / 07-pagination / end / cursor-based-pagination / src / models / song.js View on Github external
import mongoose from 'mongoose';
import URLSlugs from 'mongoose-url-slugs';
import mongoPagination from 'mongo-cursor-pagination';

const Song = mongoose.Schema({
    title: String
}, {
   timestamps: true
});

Song.plugin(URLSlugs('title', { field: 'slug', update: true }));
Song.plugin(mongoPagination.mongoosePlugin);

export default mongoose.model('Song', Song);

mongo-cursor-pagination

Make it easy to return cursor-paginated results from a Mongo collection

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis