@dhyasama/totem-models 11.11.0 → 11.13.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 +6 -5
- package/lib/Interaction.js +32 -0
- package/package.json +1 -1
package/lib/DiffbotArticle.js
CHANGED
|
@@ -12,13 +12,14 @@ module.exports = function(mongoose, config) {
|
|
|
12
12
|
org: {
|
|
13
13
|
type: Schema.ObjectId,
|
|
14
14
|
ref: 'Organization',
|
|
15
|
-
required:
|
|
16
|
-
default: null
|
|
15
|
+
required: true
|
|
17
16
|
},
|
|
18
17
|
|
|
19
|
-
updatedOn: { type: Date, required:
|
|
18
|
+
updatedOn: { type: Date, required: true },
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
entityId: { type: String, required: true, unique: true },
|
|
21
|
+
|
|
22
|
+
entity: { type: Schema.Types.Mixed, required: true },
|
|
22
23
|
|
|
23
24
|
});
|
|
24
25
|
|
|
@@ -62,7 +63,7 @@ module.exports = function(mongoose, config) {
|
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
DiffbotArticle.set('usePushEach', true);
|
|
65
|
-
DiffbotArticle.set('autoIndex',
|
|
66
|
+
DiffbotArticle.set('autoIndex', true);
|
|
66
67
|
DiffbotArticle.on('index', function(err) { console.log('error building DiffbotArticle indexes: ' + err); });
|
|
67
68
|
|
|
68
69
|
mongoose.model('DiffbotArticle', DiffbotArticle);
|
package/lib/Interaction.js
CHANGED
|
@@ -85,6 +85,38 @@ module.exports = function(mongoose, config) {
|
|
|
85
85
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
Interaction.statics.getById = function getById(id, options, cb) {
|
|
89
|
+
|
|
90
|
+
const self = this;
|
|
91
|
+
|
|
92
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
93
|
+
if (!id) { return cb(new Error('id is required'), null); }
|
|
94
|
+
if (!mongoose.Types.ObjectId.isValid(id)) { return cb(new Error('id is not a valid ObjectId'), null); }
|
|
95
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
96
|
+
|
|
97
|
+
options = helpers.getDefaultOptions(options);
|
|
98
|
+
|
|
99
|
+
if (!options.isWorkerProcess) {
|
|
100
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
101
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let query = self.findById(id);
|
|
105
|
+
|
|
106
|
+
query.populate('attendees.internal');
|
|
107
|
+
query.populate('attendees.external');
|
|
108
|
+
|
|
109
|
+
query.exec(function(err, result) {
|
|
110
|
+
|
|
111
|
+
if (err) { return cb(err, null); }
|
|
112
|
+
|
|
113
|
+
if (options.isWorkerProcess) { return cb(null, result); }
|
|
114
|
+
else { return cb(null, result); }
|
|
115
|
+
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
};
|
|
119
|
+
|
|
88
120
|
Interaction.statics.getForCustomer = function getForCustomer(customerId, since, cb) {
|
|
89
121
|
|
|
90
122
|
if (!cb) { throw new Error('cb is required'); }
|