@dhyasama/totem-models 12.12.0 → 12.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/DiffbotArticle.js +9 -7
- package/lib/DiffbotOrganization.js +9 -7
- package/lib/News.js +8 -5
- package/package.json +1 -1
package/lib/DiffbotArticle.js
CHANGED
|
@@ -60,13 +60,15 @@ module.exports = function(mongoose, config) {
|
|
|
60
60
|
DiffbotArticle.statics.upsert = function (doc, cb) {
|
|
61
61
|
|
|
62
62
|
const run = async () => {
|
|
63
|
-
doc.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
const update = doc.toObject ? doc.toObject() : doc;
|
|
64
|
+
delete update._id;
|
|
65
|
+
delete update.__v;
|
|
66
|
+
update.updatedOn = new Date();
|
|
67
|
+
return await this.findOneAndUpdate(
|
|
68
|
+
{ entityId: update.entityId },
|
|
69
|
+
update,
|
|
70
|
+
{ upsert: true, new: true }
|
|
71
|
+
);
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
if (typeof cb === 'function') { run().then(result => cb(null, result), err => cb(err)); return; }
|
|
@@ -59,13 +59,15 @@ module.exports = function(mongoose, config) {
|
|
|
59
59
|
DiffbotOrganization.statics.upsert = function (doc, cb) {
|
|
60
60
|
|
|
61
61
|
const run = async () => {
|
|
62
|
-
doc.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
const update = doc.toObject ? doc.toObject() : doc;
|
|
63
|
+
delete update._id;
|
|
64
|
+
delete update.__v;
|
|
65
|
+
update.updatedOn = new Date();
|
|
66
|
+
return await this.findOneAndUpdate(
|
|
67
|
+
{ org: update.org },
|
|
68
|
+
update,
|
|
69
|
+
{ upsert: true, new: true }
|
|
70
|
+
);
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
if (typeof cb === 'function') { run().then(result => cb(null, result), err => cb(err)); return; }
|
package/lib/News.js
CHANGED
|
@@ -115,11 +115,14 @@ module.exports = function(mongoose, config) {
|
|
|
115
115
|
News.statics.upsert = function (news, cb) {
|
|
116
116
|
|
|
117
117
|
const run = async () => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
const update = news.toObject ? news.toObject() : news;
|
|
119
|
+
delete update._id;
|
|
120
|
+
delete update.__v;
|
|
121
|
+
return await this.findOneAndUpdate(
|
|
122
|
+
{ diffbotUri: update.diffbotUri },
|
|
123
|
+
update,
|
|
124
|
+
{ upsert: true, new: true }
|
|
125
|
+
);
|
|
123
126
|
};
|
|
124
127
|
|
|
125
128
|
if (typeof cb === 'function') { run().then(result => cb(null, result), err => cb(err)); return; }
|