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 sql
18
19import (
20 "github.com/siyuan-note/logging"
21)
22
23type FileAnnotationRef struct {
24 ID string
25 FilePath string
26 AnnotationID string
27 BlockID string
28 RootID string
29 Box string
30 Path string
31 Content string
32 Type string
33}
34
35func QueryRefIDsByAnnotationID(annotationID string) (refIDs []string) {
36 refIDs = []string{}
37 rows, err := query("SELECT block_id FROM file_annotation_refs WHERE annotation_id = ?", annotationID)
38 if err != nil {
39 logging.LogErrorf("sql query failed: %s", err)
40 return
41 }
42 defer rows.Close()
43 for rows.Next() {
44 var id string
45 if err = rows.Scan(&id); err != nil {
46 logging.LogErrorf("query scan field failed: %s", err)
47 return
48 }
49 refIDs = append(refIDs, id)
50 }
51 return
52}