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 getTimestamp: function(cb
)
43 db
.serialize(function() {
47 "ORDER BY added DESC " +
49 db
.get(query
, (err
,ts
) => {
55 update: function(news
)
57 db
.serialize(function() {
61 "WHERE id = " + news
.id
;
62 db
.run(query
, news
.content
);
68 db
.serialize(function() {
77 module
.exports
= NewsModel
;