Comparing version 6.0.1 to 6.1.0
@@ -110,4 +110,9 @@ 'use strict'; | ||
insert(items, callback) { | ||
insert(items, options, callback) { | ||
if (!callback) { | ||
callback = options; | ||
options = {}; | ||
} | ||
Id.wrap(this, items, (err, wrapped) => { | ||
@@ -125,3 +130,3 @@ | ||
this._run(this._table.insert(wrapped), 'insert', wrapped, callback, (ignore, result) => { | ||
this._run(this._table.insert(wrapped, { conflict: options.merge ? 'update' : 'error' }), 'insert', wrapped, callback, (ignore, result) => { | ||
@@ -128,0 +133,0 @@ // Single item |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "6.0.1", | ||
"version": "6.1.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur", |
@@ -444,2 +444,31 @@ 'use strict'; | ||
it('updates a record if exists', (done) => { | ||
const db = new Penseur.Db('penseurtest'); | ||
db.establish(['test'], (err) => { | ||
expect(err).to.not.exist(); | ||
db.test.insert({ id: 1, a: 1, b: 1 }, { merge: true }, (err, keys1) => { | ||
expect(err).to.not.exist(); | ||
db.test.get(1, (err, item1) => { | ||
expect(err).to.not.exist(); | ||
expect(item1).to.equal({ id: 1, a: 1, b: 1 }); | ||
db.test.insert({ id: 1, a: 2 }, { merge: true }, (err, keys2) => { | ||
expect(err).to.not.exist(); | ||
db.test.get(1, (err, item2) => { | ||
expect(err).to.not.exist(); | ||
expect(item2).to.equal({ id: 1, a: 2, b: 1 }); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it('returns the generate key', (done) => { | ||
@@ -446,0 +475,0 @@ |
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
190126
4540