backbone-db-elasticsearch
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -95,6 +95,10 @@ var _ = require('lodash'); | ||
} | ||
this.client.update(this.getESOptions(model, { | ||
var updateOpts = this.getESOptions(model, { | ||
includeBody: true, | ||
update: true | ||
}), function(error, resp) { | ||
}); | ||
if (options.upsert) { | ||
updateOpts.body.upsert = _.clone(updateOpts.body.doc); | ||
} | ||
this.client.update(updateOpts, function(error, resp) { | ||
callback(error, model.toJSON()); | ||
@@ -101,0 +105,0 @@ }); |
{ | ||
"name": "backbone-db-elasticsearch", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Elasticsearch driver for backbone-db", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -90,2 +90,25 @@ var setup = require('./setup'); | ||
it('should upsert a document', function() { | ||
var model2 = new this.Model({id: 2, value: 99}); | ||
return model2.save(null, { | ||
update: true, | ||
upsert: true | ||
}); | ||
}); | ||
it('should fetch upserted doc', function() { | ||
var model2 = new this.Model({id: 2}); | ||
return model2 | ||
.fetch() | ||
.then(function() { | ||
var json = model2.toJSON(); | ||
json.value.should.equal(99); | ||
}); | ||
}); | ||
it('should delete the upserted doc', function() { | ||
var model2 = new this.Model({id: 2}); | ||
return model2.destroy(); | ||
}); | ||
describe('Index CRUD', function() { | ||
@@ -92,0 +115,0 @@ it('should create index', function(next) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33077
905