feathers-elasticsearch
Advanced tools
Comparing version 1.3.1 to 1.4.0
# Change Log | ||
## [v1.3.1](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/tree/v1.3.1) (2018-06-03) | ||
[Full Changelog](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/compare/v1.3.0...v1.3.1) | ||
**Closed issues:** | ||
- Travis horror [\#53](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/issues/53) | ||
**Merged pull requests:** | ||
- Update uberproto to the latest version 🚀 [\#52](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/pull/52) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
- Update sinon to the latest version 🚀 [\#50](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/pull/50) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
## [v1.3.0](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/tree/v1.3.0) (2018-05-16) | ||
@@ -4,0 +16,0 @@ [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-elasticsearch/compare/v1.2.0...v1.3.0) |
@@ -11,3 +11,3 @@ 'use strict'; | ||
let getParams = Object.assign( | ||
removeProps(params, 'query'), | ||
removeProps(params, 'query', 'upsert'), | ||
{ | ||
@@ -22,3 +22,3 @@ query: Object.assign( | ||
// Our `create` supports both forms. | ||
let method = id !== undefined ? 'create' : 'index'; | ||
let method = id !== undefined && !params.upsert ? 'create' : 'index'; | ||
@@ -25,0 +25,0 @@ return service.Model[method](createParams) |
@@ -10,2 +10,8 @@ 'use strict'; | ||
let updateParams = getUpdateParams(service, docDescriptor); | ||
if (params.upsert) { | ||
return service.Model.index(updateParams) | ||
.then(result => get(service, result._id, removeProps(params, 'upsert'))); | ||
} | ||
let getParams = Object.assign( | ||
@@ -22,3 +28,2 @@ removeProps(params, 'query'), | ||
// The first get is a bit of an overhead, as per the spec we want to update only existing elements. | ||
// TODO: add `allowUpsert` option which will allow upserts and allieviate the need for the first get. | ||
return get(service, id, getParams) | ||
@@ -25,0 +30,0 @@ .then(() => service.Model.index(updateParams)) |
@@ -14,2 +14,4 @@ 'use strict'; | ||
$prefix: 'filter.prefix', | ||
$wildcard: 'filter.wildcard', | ||
$regexp: 'filter.regexp', | ||
$match: 'must.match', | ||
@@ -16,0 +18,0 @@ $phrase: 'must.match_phrase', |
{ | ||
"name": "feathers-elasticsearch", | ||
"description": "Elasticsearch adapter for FeathersJs", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"homepage": "https://github.com/feathersjs-ecosystem/feathers-elasticsearch", | ||
@@ -45,3 +45,3 @@ "main": "lib/", | ||
"@feathersjs/errors": "^3.2.0", | ||
"debug": "^3.1.0", | ||
"debug": "^4.0.0", | ||
"uberproto": "^2.0.0" | ||
@@ -55,9 +55,9 @@ }, | ||
"elasticsearch": "^15.0.0", | ||
"eslint": "^4.19.1", | ||
"eslint": "^5.0.0", | ||
"feathers-service-tests": "^0.10.0", | ||
"mocha": "^5.0.0", | ||
"nyc": "^12.0.1", | ||
"semistandard": "^12.0.1", | ||
"sinon": "^5.0.8" | ||
"semistandard": "^13.0.0", | ||
"sinon": "^6.0.0" | ||
} | ||
} |
@@ -127,2 +127,26 @@ # feathers-elasticsearch | ||
### $wildcard | ||
[Term level query `wildcard`](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html). Find all documents which have given field containing terms matching a wildcard expression (not analyzed). | ||
```js | ||
query: { | ||
user: { | ||
$wildcard: 'B*b' | ||
} | ||
} | ||
``` | ||
### $regexp | ||
[Term level query `regexp`](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html). Find all documents which have given field containing terms matching a regular expression (not analyzed). | ||
```js | ||
query: { | ||
user: { | ||
$regexp: 'Bo[xb]' | ||
} | ||
} | ||
``` | ||
### $exists | ||
@@ -407,2 +431,30 @@ | ||
### Upsert capability | ||
An `upsert` parameter is available for the `create` operation that will update the document if it exists already instead of throwing an error. | ||
```javascript | ||
postService.create({ | ||
_id: 123, | ||
text: 'JavaScript may be flawed, but it\'s better than Ruby.' | ||
}, | ||
{ | ||
upsert: true | ||
}) | ||
``` | ||
Additionally, an `upsert` parameter is also available for the `update` operation that will create the document if it doesn't exist instead of throwing an error. | ||
```javascript | ||
postService.update(123, { | ||
_id: 123, | ||
text: 'JavaScript may be flawed, but Feathers makes it fly.' | ||
}, | ||
{ | ||
upsert: true | ||
}) | ||
``` | ||
## Born out of need | ||
@@ -409,0 +461,0 @@ |
66495
1126
469
- Removeddebug@3.2.7(transitive)
Updateddebug@^4.0.0