A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
1// SiYuan - Refactor your thinking 2// Copyright (c) 2020-present, b3log.org 3// 4// This program is free software: you can redistribute it and/or modify 5// it under the terms of the GNU Affero General Public License as published by 6// the Free Software Foundation, either version 3 of the License, or 7// (at your option) any later version. 8// 9// This program is distributed in the hope that it will be useful, 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// GNU Affero General Public License for more details. 13// 14// You should have received a copy of the GNU Affero General Public License 15// along with this program. If not, see <https://www.gnu.org/licenses/>. 16 17package api 18 19import ( 20 "net/http" 21 22 "github.com/88250/gulu" 23 "github.com/gin-gonic/gin" 24 "github.com/siyuan-note/siyuan/kernel/model" 25 "github.com/siyuan-note/siyuan/kernel/sql" 26 "github.com/siyuan-note/siyuan/kernel/util" 27) 28 29func flushTransaction(c *gin.Context) { 30 // Add internal kernel API `/api/sqlite/flushTransaction` https://github.com/siyuan-note/siyuan/issues/10005 31 ret := gulu.Ret.NewResult() 32 defer c.JSON(http.StatusOK, ret) 33 34 model.FlushTxQueue() 35 sql.FlushQueue() 36} 37 38func SQL(c *gin.Context) { 39 ret := gulu.Ret.NewResult() 40 defer c.JSON(http.StatusOK, ret) 41 42 arg, ok := util.JsonArg(c, ret) 43 if !ok { 44 return 45 } 46 47 stmt := arg["stmt"].(string) 48 result, err := sql.Query(stmt, model.Conf.Search.Limit) 49 if err != nil { 50 ret.Code = 1 51 ret.Msg = err.Error() 52 return 53 } 54 55 ret.Data = result 56}