From 3e93fa4f6c244f82df14221fd7b3beeee55106de Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Tue, 27 Feb 2018 01:09:20 +0100 Subject: [PATCH] add publish field --- blog/api.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/blog/api.lua b/blog/api.lua index 8cf478f..3cb59a9 100644 --- a/blog/api.lua +++ b/blog/api.lua @@ -1,8 +1,16 @@ local get = {} -get.fetch = function(user, exp, limit) +get.fetch = function(user, cnd, limit) local db = require("db.model").get(user,"blogs",nil) if not db then return nil end - local cond = { exp = exp, order = { ctime = "DESC" }} + local exp = {} + exp[1] = {["="] = { publish = 1 }} + if cnd then + exp[2] = cnd + else + + end + + local cond = { exp = {["and"] = exp }, order = { ctime = "DESC" }} if limit then cond.limit = limit end