Compare commits

...

5 Commits

Author SHA1 Message Date
bbuchanan9 a0d4ca7fbc squash: package-lock 2019-03-14 14:42:14 -07:00
bbuchanan9 5bb261338b squash: check for obj existence 2019-03-14 14:42:02 -07:00
bbuchanan9 8dabd00a29 squash: getTag -> generateNewTag 2019-03-14 13:09:36 -07:00
bbuchanan9 906ca3d6a4 squash: condPut -> cond 2019-03-11 16:58:47 -07:00
bbuchanan9 5d230673cc feature: ZENKO-1438 Add conditional MD puts 2019-03-11 16:46:57 -07:00
3 changed files with 568 additions and 544 deletions

View File

@ -356,7 +356,9 @@ class MongoClientInterface {
_id: vObjName,
},
update: {
_id: vObjName, value: objVal,
_id: vObjName,
tag: MongoUtils.generateNewTag(),
value: objVal,
},
upsert: true,
},
@ -378,7 +380,9 @@ class MongoClientInterface {
],
},
update: {
_id: objName, value: objVal,
_id: objName,
tag: MongoUtils.generateNewTag(),
value: objVal,
},
upsert: true,
},
@ -419,14 +423,18 @@ class MongoClientInterface {
const versionId = generateVersionId(this.replicationGroupId);
// eslint-disable-next-line
objVal.versionId = versionId;
c.update({
_id: objName,
}, {
const query = { _id: objName };
const update = {
_id: objName,
tag: MongoUtils.generateNewTag(),
value: objVal,
}, {
upsert: true,
}, err => {
};
const options = { upsert: true };
if (params.cond && params.cond.tag) {
query.tag = params.cond.tag;
options.upsert = false;
}
c.update(query, update, options, err => {
if (err) {
log.error(
'putObjectVerCase2: error putting object version',
@ -451,12 +459,19 @@ class MongoClientInterface {
// eslint-disable-next-line
objVal.versionId = params.versionId;
const vObjName = formatVersionKey(objName, params.versionId);
c.findOne({ _id: objName }, (err, checkObj) => {
const query = { _id: objName };
if (params.cond && params.cond.tag) {
query.tag = params.cond.tag;
}
c.findOne(query, (err, checkObj) => {
if (err) {
log.error('putObjectVerCase3: mongoDB error finding object');
return cb(errors.InternalError);
}
const objUpsert = !checkObj;
if (objUpsert && params.cond && params.cond.tag) {
return cb();
}
c.bulkWrite([{
updateOne: {
filter: {
@ -465,6 +480,7 @@ class MongoClientInterface {
update: {
$set: {
_id: vObjName,
tag: MongoUtils.generateNewTag(),
value: objVal,
},
},
@ -480,6 +496,7 @@ class MongoClientInterface {
update: {
$set: {
_id: objName,
tag: MongoUtils.generateNewTag(),
value: objVal,
},
},
@ -512,14 +529,18 @@ class MongoClientInterface {
* Put object when versioning is not enabled
*/
putObjectNoVer(c, bucketName, objName, objVal, params, log, cb) {
c.update({
_id: objName,
}, {
const query = { _id: objName };
const update = {
_id: objName,
tag: MongoUtils.generateNewTag(),
value: objVal,
}, {
upsert: true,
}, err => {
};
const options = { upsert: true };
if (params.cond && params.cond.tag) {
query.tag = params.cond.tag;
options.upsert = false;
}
c.update(query, update, options, err => {
if (err) {
log.error(
'putObjectNoVer: error putting obect with no versioning',

View File

@ -1,3 +1,4 @@
const uuid = require('uuid/v4');
function escape(obj) {
return JSON.parse(JSON.stringify(obj).
@ -27,4 +28,8 @@ function unserialize(objMD) {
}
}
module.exports = { escape, unescape, serialize, unserialize };
function generateNewTag() {
return uuid();
}
module.exports = { escape, unescape, serialize, unserialize, generateNewTag };

1054
package-lock.json generated

File diff suppressed because it is too large Load Diff