1 const db
= require("../utils/database");
13 create: function(content
, uid
, cb
)
15 db
.serialize(function() {
18 "(added, uid, content) " +
20 "(" + Date
.now() + "," + uid
+ ",?)";
21 db
.run(query
, content
, function(err
) {
22 cb(err
, { id: this.lastID
});
27 getNext: function(cursor
, cb
)
29 db
.serialize(function() {
33 "WHERE added < " + cursor
+ " " +
34 "ORDER BY added DESC " +
35 "LIMIT 10"; //TODO: 10 currently hard-coded
36 db
.all(query
, (err
,newsList
) => {
42 getTimestamp: function(cb
)
44 db
.serialize(function() {
48 "ORDER BY added DESC " +
50 db
.get(query
, (err
,ts
) => {
56 update: function(news
)
58 db
.serialize(function() {
62 "WHERE id = " + news
.id
;
63 db
.run(query
, news
.content
);
69 db
.serialize(function() {
78 module
.exports
= NewsModel
;