MCPcopy Index your code
hub / github.com/dnote/dnote / doQuery

Function doQuery

pkg/cli/cmd/find/find.go:130–151  ·  view source on GitHub ↗
(ctx context.DnoteCtx, query, bookName string)

Source from the content-addressed store, hash-verified

128}
129
130func doQuery(ctx context.DnoteCtx, query, bookName string) (*sql.Rows, error) {
131 db := ctx.DB
132
133 sql := `SELECT
134 notes.rowid,
135 books.label AS book_label,
136 snippet(note_fts, 0, '<dnotehl>', '</dnotehl>', '...', 28)
137 FROM note_fts
138 INNER JOIN notes ON notes.rowid = note_fts.rowid
139 INNER JOIN books ON notes.book_uuid = books.uuid
140 WHERE note_fts MATCH ?`
141 args := []interface{}{query}
142
143 if bookName != "" {
144 sql = fmt.Sprintf("%s AND books.label = ?", sql)
145 args = append(args, bookName)
146 }
147
148 rows, err := db.Query(sql, args...)
149
150 return rows, err
151}
152
153func newRun(ctx context.DnoteCtx) infra.RunEFunc {
154 return func(cmd *cobra.Command, args []string) error {

Callers 1

newRunFunction · 0.85

Calls 1

QueryMethod · 0.65

Tested by

no test coverage detected