@dhyasama/totem-models 10.77.0 → 10.79.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/News.js +33 -2
- package/package.json +1 -1
package/lib/News.js
CHANGED
|
@@ -6,6 +6,7 @@ module.exports = function(mongoose, config) {
|
|
|
6
6
|
|
|
7
7
|
Schema = mongoose.Schema,
|
|
8
8
|
_ = require('underscore'),
|
|
9
|
+
helpers = require('../helpers'),
|
|
9
10
|
|
|
10
11
|
News = new Schema({
|
|
11
12
|
|
|
@@ -36,11 +37,24 @@ module.exports = function(mongoose, config) {
|
|
|
36
37
|
|
|
37
38
|
text: { type: String, required: false, default: null },
|
|
38
39
|
|
|
40
|
+
analysis: {
|
|
41
|
+
relevant: { type: Boolean, default: false },
|
|
42
|
+
summary: { type: String }
|
|
43
|
+
},
|
|
44
|
+
|
|
39
45
|
});
|
|
40
46
|
|
|
41
|
-
News.statics.
|
|
47
|
+
News.statics.getById = function getById(id, options, cb) {
|
|
48
|
+
|
|
49
|
+
const self = this;
|
|
50
|
+
|
|
51
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
52
|
+
if (!id) { return cb(new Error('ids is required'), null); }
|
|
53
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
42
54
|
|
|
43
|
-
|
|
55
|
+
options = helpers.getDefaultOptions(options);
|
|
56
|
+
|
|
57
|
+
self
|
|
44
58
|
.find({ org: id })
|
|
45
59
|
.populate('org')
|
|
46
60
|
.sort('-createdOn')
|
|
@@ -48,6 +62,23 @@ module.exports = function(mongoose, config) {
|
|
|
48
62
|
|
|
49
63
|
};
|
|
50
64
|
|
|
65
|
+
News.statics.getByIds = function getByIds(ids, options, cb) {
|
|
66
|
+
|
|
67
|
+
const self = this;
|
|
68
|
+
|
|
69
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
70
|
+
if (!ids) { return cb(new Error('ids is required'), null); }
|
|
71
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
72
|
+
|
|
73
|
+
options = helpers.getDefaultOptions(options);
|
|
74
|
+
|
|
75
|
+
self
|
|
76
|
+
.find({ org: { $in : ids } })
|
|
77
|
+
.sort('-createdOn')
|
|
78
|
+
.exec(cb);
|
|
79
|
+
|
|
80
|
+
};
|
|
81
|
+
|
|
51
82
|
News.statics.modifyById = function(id, update, cb) {
|
|
52
83
|
|
|
53
84
|
// VERY IMPORTANT NOTE
|