summaryrefslogtreecommitdiff
path: root/lib/db/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-03-31 14:52:57 +0200
committerJules Laplace <julescarbon@gmail.com>2018-03-31 14:52:57 +0200
commita7b2a2c8929ec1d17939f2527ac6033beeaea9b7 (patch)
treec7e94a12caaf14a1d0ce8842f00590b07b381d20 /lib/db/index.js
parentc3d17983b398b5c5b2c2c62dd8fff478b5f02b4d (diff)
ascii view
Diffstat (limited to 'lib/db/index.js')
-rw-r--r--lib/db/index.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/db/index.js b/lib/db/index.js
index b2ea59c..ffd8c27 100644
--- a/lib/db/index.js
+++ b/lib/db/index.js
@@ -4,7 +4,6 @@ var connection = require("./bookshelf")
var bookshelf = connection.bookshelf
var knex = connection.knex
-
/* MODELS */
var Image = db.Image = bookshelf.Model.extend({
@@ -30,6 +29,11 @@ db.getRandom = function () {
qb.orderBy(knex.raw('RAND()')).limit(1)
}).fetch()
}
+db.getRandomAscii = function () {
+ return ShaderImage.query(function(qb){
+ qb.where("tag", "=", "ascii").orderBy(knex.raw('RAND()')).limit(1)
+ }).fetch()
+}
db.getIndex = function(limit, offset) {
return Image.query(function(qb){
qb.orderBy("id", "desc").limit(limit)