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
, {nid: this.lastID
});
27 getNext: function(cursor
, cb
)
29 db
.serialize(function() {
33 "WHERE id > " + cursor
+ " " +
34 "LIMIT 10"; //TODO: 10 currently hard-coded
35 db
.all(query
, (err
,newsList
) => {
41 update: function(news
)
43 db
.serialize(function() {
47 "WHERE id = " + news
.id
;
48 db
.run(query
, news
.content
);
54 db
.serialize(function() {
63 module
.exports
= NewsModel
;