Skip to content

Commit 9308d46

Browse files
committed
no key for upsert
1 parent 448139a commit 9308d46

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ So it's insert. More you can read here: http://tarantool.org/doc/book/box/box_sp
113113

114114
Promise resolve a new tuple.
115115

116-
**upsert(spaceId: Number or String, key: tuple, ops: array of operations, tuple: tuple) : Promise()**
116+
**upsert(spaceId: Number or String, ops: array of operations, tuple: tuple) : Promise()**
117117

118118
About operation: http://tarantool.org/doc/book/box/box_space.html#lua-function.space_object.upsert
119119

lib/connection.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,14 @@ TarantoolConnection.prototype.update = function(spaceId, indexId, key, ops){
454454

455455

456456

457-
TarantoolConnection.prototype.upsert = function(spaceId, key, ops, tuple){
457+
TarantoolConnection.prototype.upsert = function(spaceId, ops, tuple){
458458
return new Promise(function (resolve, reject) {
459-
if (Number.isInteger(key))
460-
key = [key];
461459
if (Array.isArray(ops) && Array.isArray(key)){
462460
if (typeof(spaceId)=='string')
463461
{
464462
return this._getMetadata(spaceId, 0)
465463
.then(function(info){
466-
return this.upsert(info[0], key, ops, tuple);
464+
return this.upsert(info[0], ops, tuple);
467465
}.bind(this))
468466
.then(resolve)
469467
.catch(reject);
@@ -472,14 +470,10 @@ TarantoolConnection.prototype.upsert = function(spaceId, key, ops, tuple){
472470
var header = this._header(tarantoolConstants.RequestCode.rqUpsert, reqId);
473471
var buffered = {
474472
spaceId: this.msgpack.encode(spaceId),
475-
//indexId: msgpack.encode(indexId),
476473
ops: this.msgpack.encode(ops),
477-
key: this.msgpack.encode(key),
478474
tuple: this.msgpack.encode(tuple)
479475
};
480476
var body = Buffer.concat([new Buffer([0x84,tarantoolConstants.KeysCode.space_id]), buffered.spaceId,
481-
//new Buffer([tarantoolConstants.KeysCode.index_id]), buffered.indexId,
482-
new Buffer([tarantoolConstants.KeysCode.key]), buffered.key,
483477
new Buffer([tarantoolConstants.KeysCode.def_tuple]), buffered.ops,
484478
new Buffer([tarantoolConstants.KeysCode.tuple]), buffered.tuple]);
485479
if (this.options.log)

0 commit comments

Comments
 (0)