Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lucis-api-query

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lucis-api-query - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

41

index.js

@@ -159,8 +159,7 @@ function pluginMongoose (schema) {

query = query || {};
options = Object.assign({}, paginate.options, options);
options = Object.assign({}, options);
let select = options.select;
let sort = options.sort;
let populate = options.populate;
let lean = options.lean || true;
let leanWithId = options.leanWithId || true;
let lean = options.lean === false ? false : true;
let limit = options.limit ? options.limit : 10;

@@ -206,6 +205,10 @@ let page, offset, skip, promises;

return Promise.all(promises).then((data) => {
// Por algum motivo isso funcionou algum dia, mesmo ele transformando em array...
// TODO: Melhorar a busca paralele
const docs = data[0];
const total = data[1];
let result = {
docs: data.docs,
total: data.count,
limit: limit
docs,
total,
limit
};

@@ -217,3 +220,3 @@ if (offset !== undefined) {

result.page = page;
result.pages = Math.ceil(data.count / limit) || 1;
result.pages = Math.ceil(total / limit) || 1;
}

@@ -280,3 +283,3 @@ if (typeof callback === 'function') {

// Data regarding selection and paginate
const { select, paginate } = req.query;
let { select, paginate } = req.query;
select = (typeof select === 'string') ? select.replace(',', ' ') : null;

@@ -293,26 +296,4 @@ paginate = (typeof paginate === 'string') ? paginate.replace(',', ' ') : null;

// TODO: Não deve ser necessário
// function montaEntidadePaginacao(resposta){
// return {
// totalDeEntidades: resposta.total,
// entidades: resposta.docs,
// pagina: resposta.page,
// resultadosPorPagina: resposta.limit,
// totalDePaginas: resposta.pages
// }
// };
// TODO: Não deve ser necessário
// function montaConfigPaginacao(paginacao, campos, populate){
// return {
// page: paginacao.pagina,
// limit: paginacao.resultadosPorPagina,
// lean: true,
// select: campos,
// populate: populate
// };
// };
const biblioteca = {pluginMongoose};
module.exports = exports = biblioteca;
{
"name": "lucis-api-query",
"version": "0.0.5",
"version": "0.1.0",
"description": "Adaptação do mongoose-api-query para necessidades mais comuns",

@@ -5,0 +5,0 @@ "main": "index.js",

# lucis-api-query
## Motivação
This library merge three other libraries used for paginating and querying resources in Mongoose: `mongoose-paginate`, `mongoose-api-query` and.
## Motivation
This library merge three other libraries used for paginating and querying resources in Mongoose: `mongoose-paginate`, `mongoose-api-query` and. *You will just import and set it on Mongoose and pagination + advanced querying will work out of the box!*

@@ -6,0 +6,0 @@ `mongoose-paginate` works creating a query in the database using pagination's parameters.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc