microgen-mongoose
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -45,3 +45,2 @@ "use strict"; | ||
// throw new errors_1.BadRequest(`Invalid query parameter ${key}`, query); | ||
return; | ||
} | ||
@@ -48,0 +47,0 @@ } |
@@ -45,2 +45,15 @@ const { _ } = require('@feathersjs/commons'); | ||
_filterQuery(params = {}, opts = {}) { | ||
const paginate = typeof params.paginate !== 'undefined' | ||
? params.paginate : this.options.paginate; | ||
const { query = {} } = params; | ||
const options = Object.assign({ | ||
operators: this.options.whitelist || [], | ||
filters: this.options.filters, | ||
paginate | ||
}, opts); | ||
const result = filterQuery(query, options); | ||
return Object.assign(result, { paginate }); | ||
} | ||
_getOrFind (id, params = {}) { | ||
@@ -55,3 +68,3 @@ if (id === null) { | ||
_find (params = {}) { | ||
const { filters, query, paginate } = filterQuery(params); | ||
const { filters, query, paginate } = this._filterQuery(params); | ||
const discriminator = (params.query || {})[this.discriminatorKey] || this.discriminatorKey; | ||
@@ -62,2 +75,3 @@ const model = this.discriminators[discriminator] || this.Model; | ||
console.log(query, filters) | ||
// Handle $addFields | ||
@@ -138,3 +152,3 @@ if (query.$addFields) { | ||
_get (id, params = {}) { | ||
const { query, filters } = filterQuery(params); | ||
const { query, filters } = this._filterQuery(params); | ||
@@ -228,3 +242,3 @@ query.$and = (query.$and || []).concat([{ [this.id]: id }]); | ||
const { query, filters } = filterQuery(params); | ||
const { query, filters } = this._filterQuery(params); | ||
const options = Object.assign({ | ||
@@ -269,3 +283,3 @@ new: true, | ||
_patch (id, data, params = {}) { | ||
const { query } = filterQuery(params); | ||
const { query } = this._filterQuery(params); | ||
const mapIds = data => Array.isArray(data) ? data.map(current => current[this.id]) : [data[this.id]]; | ||
@@ -345,3 +359,3 @@ | ||
_remove (id, params = {}) { | ||
const { query } = filterQuery(params); | ||
const { query } = this._filterQuery(params); | ||
@@ -348,0 +362,0 @@ if (params.collation) { |
{ | ||
"name": "microgen-mongoose", | ||
"description": "A Microgen service adapter for the Mongoose ORM", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"homepage": "https://github.com/feathersjs-ecosystem/feathers-mongoose", | ||
@@ -6,0 +6,0 @@ "main": "lib/", |
100500
670