feathers-solr
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -124,2 +124,21 @@ const { _ } = require('@feathersjs/commons'); | ||
async _update(id, data, params = {}) { | ||
const sel = select(params, this.id); | ||
const dataToUpdate = await this._getOrFind(id, params); | ||
if (!dataToUpdate[this.id]) { | ||
throw new errors.NotFound('No record found'); | ||
} | ||
data[this.id] = id || dataToUpdate[this.id]; | ||
// update | ||
await this.Model.post('update/json', [data], Object.assign(params, this.commit)); | ||
// get updated data | ||
const updatedData = await this._getOrFind(id, params); | ||
return _.omit(sel(updatedData), 'score', '_version_'); | ||
} | ||
async _remove(id, params = {}) { | ||
@@ -138,3 +157,3 @@ if (id === null && _.isEmpty(params)) { | ||
// delete | ||
const response = await this.Model.post('update/json', query, Object.assign(this.commit)); | ||
await this.Model.post('update/json', query, Object.assign(this.commit)); | ||
@@ -144,19 +163,22 @@ return sel(dataToDelete); | ||
async _update(id, data, params = {}) { | ||
const sel = select(params, this.id); | ||
const dataToUpdate = await this._getOrFind(id, params); | ||
filterQuery(params = {}) { | ||
const filtered = super.filterQuery(params); | ||
if (!dataToUpdate[this.id]) { | ||
throw new errors.NotFound('No record found'); | ||
// inject search options | ||
if (_.has(filtered, 'query.$search')) { | ||
const params = Object.assign(this.search, filtered.query.$params); | ||
if (!_.isEmpty(params)) filtered.query.$params = params; | ||
} | ||
data[this.id] = id || dataToUpdate[this.id]; | ||
// inject suggest options | ||
if (_.has(filtered, 'query.$suggest')) { | ||
filtered.query.$params = Object.assign(this.search, filtered.query.$params); | ||
} | ||
// update | ||
const response = await this.Model.post('update/json', [data], Object.assign(params, this.commit)); | ||
// inject spellcheck options | ||
if (_.has(filtered, 'query.$spellcheck')) { | ||
filtered.query.$params = Object.assign(this.search, filtered.query.$params); | ||
} | ||
// get updated data | ||
const updatedData = await this._getOrFind(id, params); | ||
return _.omit(sel(updatedData), 'score', '_version_'); | ||
return filtered; | ||
} | ||
@@ -163,0 +185,0 @@ } |
{ | ||
"name": "feathers-solr", | ||
"description": "A service plugin for Solr", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"homepage": "https://github.com/sajov/feathers-solr", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
76731
1807