summaryrefslogtreecommitdiff
path: root/bucky/db/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/db/index.js')
-rw-r--r--bucky/db/index.js42
1 files changed, 35 insertions, 7 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js
index 77e94fa..f376308 100644
--- a/bucky/db/index.js
+++ b/bucky/db/index.js
@@ -58,12 +58,11 @@ db.getLastlog = function(limit){
return knex.column('username').column('lastseen').select().from('users').orderBy('lastseen', 'desc').limit(limit || 10)
}
-
/* THREADS */
db.getLatestThreads = function () {
return Thread.query(function(qb){
- qb.orderBy("id", "desc").limit(50)
+ qb.orderBy("lastmodified", "desc").limit(50)
}).fetchAll()
}
db.getThreadsForKeyword = function (keyword) {
@@ -74,7 +73,13 @@ db.getThreadsForKeyword = function (keyword) {
db.getThread = function (id) {
return Thread.query("where", "id", "=", id).fetch()
}
-
+db.createThread = function(data){
+ return new db.Thread(data).save()
+}
+db.updateThread = function(data){
+}
+db.removeThread = function(id){
+}
/* FILES */
@@ -87,7 +92,11 @@ db.getFileCounts = function(ids){
db.getFileSizes = function(ids){
return knex.column('thread').sum('size as size').select().from('files').where('thread', 'in', ids).groupBy('thread')
}
-
+db.createFile = function(data){
+ return new db.File(data).save()
+}
+db.removeFile = function(id){
+}
/* COMMENTS */
@@ -111,8 +120,12 @@ db.getCommentsForThread = function (id, limit, offset, order){
db.getCommentCounts = function(ids){
return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread')
}
-db.createComment = function(comment){
- return new Comment(comment).save()
+db.createComment = function(data){
+ return new db.Comment(data).save()
+}
+db.updateComment = function(data){
+}
+db.removeComment = function(id){
}
@@ -124,6 +137,13 @@ db.getKeywords = function (keywords){
db.getKeyword = function (keyword) {
return Keyword.query("where", "keyword", "=", keyword).fetch()
}
+db.createKeyword = function(data){
+ return new db.Keyword(data).save()
+}
+db.updateKeyword = function(data){
+}
+db.removeKeyword = function(id){
+}
/* MAILBOXES */
@@ -134,7 +154,8 @@ db.getMailboxes = function(username){
db.getMailboxCounts = function(boxes){
return knex.column('mbox').count('* as count').select().from('messages').where('mbox', 'in', boxes).groupBy('mbox')
}
-
+db.createMailbox = function(data){
+}
/* MESSAGES */
@@ -157,3 +178,10 @@ db.getMessage = function (id){
return message
})
}
+db.createMessage = function(data){
+ return new db.Message(data).save()
+}
+db.updateMessage = function(data){
+}
+db.removeMessage = function(id){
+}