@dhyasama/totem-models 10.43.0 → 10.45.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/Message.js +20 -0
- package/package.json +1 -1
package/lib/Message.js
CHANGED
|
@@ -32,6 +32,13 @@ module.exports = function(mongoose, config) {
|
|
|
32
32
|
documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
|
|
33
33
|
raw: { type: Schema.Types.Mixed, required: true },
|
|
34
34
|
messageDate: { type: Date, required: true },
|
|
35
|
+
analysis: {
|
|
36
|
+
summary: { type: String },
|
|
37
|
+
insights: [{
|
|
38
|
+
text: { type: String },
|
|
39
|
+
category: { type: String, enum: ['highlight', 'lowlight', 'goal', 'ask'] }
|
|
40
|
+
}]
|
|
41
|
+
},
|
|
35
42
|
|
|
36
43
|
});
|
|
37
44
|
|
|
@@ -177,6 +184,19 @@ module.exports = function(mongoose, config) {
|
|
|
177
184
|
|
|
178
185
|
};
|
|
179
186
|
|
|
187
|
+
Message.statics.getForDocument = function getForCustomer(docId, cb) {
|
|
188
|
+
|
|
189
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
190
|
+
if (!docId) { return cb(new Error('docId is required'), null); }
|
|
191
|
+
if (!mongoose.Types.ObjectId.isValid(docId)) { return cb(new Error('docId is not a valid ObjectId'), null); }
|
|
192
|
+
|
|
193
|
+
const self = this;
|
|
194
|
+
let query = self.findOne({ documents: { $in: [docId] } });
|
|
195
|
+
|
|
196
|
+
query.exec(cb);
|
|
197
|
+
|
|
198
|
+
};
|
|
199
|
+
|
|
180
200
|
Message.statics.getForOrg = function getForOrg(orgId, options, cb) {
|
|
181
201
|
|
|
182
202
|
if (!cb) { throw new Error('cb is required'); }
|