forked from bioversity/Crop-Ontology
-
Notifications
You must be signed in to change notification settings - Fork 1
/
commentmodel.js
34 lines (26 loc) · 936 Bytes
/
commentmodel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var commentmodel = {
getCommentsByOnto: function(ontoId) {
var comments = googlestore.query("comment")
.filter("ontology_id", "=", ontoId)
.sort("created", "DESC")
.fetch();
var ret = [];
comments.forEach(function(comment) {
var c = googlestore.toJS(comment),
username = null;
try {
// need the author in clean text
var userKey = comment.getProperty("userKey"),
userEntity = googlestore.get(userKey);
username = userEntity.getProperty("username");
} catch(e) {
}
c.author = ""+username;
// keep the date as JAVA date!
c.created = comment.getProperty("created");
ret.push(c);
});
return ret;
}
};
exports = commentmodel;