Compare commits
No commits in common. "a0d4ca7fbc941b19f0850e0a036d8d0618ee12cd" and "bef886d8ad046a016b40a71e1d26276a02a98b28" have entirely different histories.
a0d4ca7fbc
...
bef886d8ad
|
@ -356,9 +356,7 @@ class MongoClientInterface {
|
||||||
_id: vObjName,
|
_id: vObjName,
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
_id: vObjName,
|
_id: vObjName, value: objVal,
|
||||||
tag: MongoUtils.generateNewTag(),
|
|
||||||
value: objVal,
|
|
||||||
},
|
},
|
||||||
upsert: true,
|
upsert: true,
|
||||||
},
|
},
|
||||||
|
@ -380,9 +378,7 @@ class MongoClientInterface {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
_id: objName,
|
_id: objName, value: objVal,
|
||||||
tag: MongoUtils.generateNewTag(),
|
|
||||||
value: objVal,
|
|
||||||
},
|
},
|
||||||
upsert: true,
|
upsert: true,
|
||||||
},
|
},
|
||||||
|
@ -423,18 +419,14 @@ class MongoClientInterface {
|
||||||
const versionId = generateVersionId(this.replicationGroupId);
|
const versionId = generateVersionId(this.replicationGroupId);
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
objVal.versionId = versionId;
|
objVal.versionId = versionId;
|
||||||
const query = { _id: objName };
|
c.update({
|
||||||
const update = {
|
_id: objName,
|
||||||
|
}, {
|
||||||
_id: objName,
|
_id: objName,
|
||||||
tag: MongoUtils.generateNewTag(),
|
|
||||||
value: objVal,
|
value: objVal,
|
||||||
};
|
}, {
|
||||||
const options = { upsert: true };
|
upsert: true,
|
||||||
if (params.cond && params.cond.tag) {
|
}, err => {
|
||||||
query.tag = params.cond.tag;
|
|
||||||
options.upsert = false;
|
|
||||||
}
|
|
||||||
c.update(query, update, options, err => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(
|
log.error(
|
||||||
'putObjectVerCase2: error putting object version',
|
'putObjectVerCase2: error putting object version',
|
||||||
|
@ -459,19 +451,12 @@ class MongoClientInterface {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
objVal.versionId = params.versionId;
|
objVal.versionId = params.versionId;
|
||||||
const vObjName = formatVersionKey(objName, params.versionId);
|
const vObjName = formatVersionKey(objName, params.versionId);
|
||||||
const query = { _id: objName };
|
c.findOne({ _id: objName }, (err, checkObj) => {
|
||||||
if (params.cond && params.cond.tag) {
|
|
||||||
query.tag = params.cond.tag;
|
|
||||||
}
|
|
||||||
c.findOne(query, (err, checkObj) => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('putObjectVerCase3: mongoDB error finding object');
|
log.error('putObjectVerCase3: mongoDB error finding object');
|
||||||
return cb(errors.InternalError);
|
return cb(errors.InternalError);
|
||||||
}
|
}
|
||||||
const objUpsert = !checkObj;
|
const objUpsert = !checkObj;
|
||||||
if (objUpsert && params.cond && params.cond.tag) {
|
|
||||||
return cb();
|
|
||||||
}
|
|
||||||
c.bulkWrite([{
|
c.bulkWrite([{
|
||||||
updateOne: {
|
updateOne: {
|
||||||
filter: {
|
filter: {
|
||||||
|
@ -480,7 +465,6 @@ class MongoClientInterface {
|
||||||
update: {
|
update: {
|
||||||
$set: {
|
$set: {
|
||||||
_id: vObjName,
|
_id: vObjName,
|
||||||
tag: MongoUtils.generateNewTag(),
|
|
||||||
value: objVal,
|
value: objVal,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -496,7 +480,6 @@ class MongoClientInterface {
|
||||||
update: {
|
update: {
|
||||||
$set: {
|
$set: {
|
||||||
_id: objName,
|
_id: objName,
|
||||||
tag: MongoUtils.generateNewTag(),
|
|
||||||
value: objVal,
|
value: objVal,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -529,18 +512,14 @@ class MongoClientInterface {
|
||||||
* Put object when versioning is not enabled
|
* Put object when versioning is not enabled
|
||||||
*/
|
*/
|
||||||
putObjectNoVer(c, bucketName, objName, objVal, params, log, cb) {
|
putObjectNoVer(c, bucketName, objName, objVal, params, log, cb) {
|
||||||
const query = { _id: objName };
|
c.update({
|
||||||
const update = {
|
_id: objName,
|
||||||
|
}, {
|
||||||
_id: objName,
|
_id: objName,
|
||||||
tag: MongoUtils.generateNewTag(),
|
|
||||||
value: objVal,
|
value: objVal,
|
||||||
};
|
}, {
|
||||||
const options = { upsert: true };
|
upsert: true,
|
||||||
if (params.cond && params.cond.tag) {
|
}, err => {
|
||||||
query.tag = params.cond.tag;
|
|
||||||
options.upsert = false;
|
|
||||||
}
|
|
||||||
c.update(query, update, options, err => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(
|
log.error(
|
||||||
'putObjectNoVer: error putting obect with no versioning',
|
'putObjectNoVer: error putting obect with no versioning',
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
const uuid = require('uuid/v4');
|
|
||||||
|
|
||||||
function escape(obj) {
|
function escape(obj) {
|
||||||
return JSON.parse(JSON.stringify(obj).
|
return JSON.parse(JSON.stringify(obj).
|
||||||
|
@ -28,8 +27,4 @@ function unserialize(objMD) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateNewTag() {
|
module.exports = { escape, unescape, serialize, unserialize };
|
||||||
return uuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { escape, unescape, serialize, unserialize, generateNewTag };
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue