0.1.6 11bec3a

inspectdb.go RawHistoryFolder

1package queries
2
3import (
4	"fmt"
5
6	"github.com/bnema/gordon/internal/server"
7)
8
9// InspectInMemoryDB inspects the in-memory database. (for debug purpose)
10func InspectInMemoryDB(a *server.App) error {
11	memDb := a.DB
12	// Query the sqlite_master table to get a list of all tables
13	rows, err := memDb.Query("SELECT name FROM sqlite_master WHERE type='table'")
14	fmt.Println("rows", rows)
15	if err != nil {
16		return err
17	}
18	defer rows.Close()
19
20	var tables []string
21	for rows.Next() {
22		var tableName string
23		if err := rows.Scan(&tableName); err != nil {
24			return err
25		}
26		tables = append(tables, tableName)
27	}
28
29	if err := rows.Err(); err != nil {
30		return err
31	}
32
33	// Print the tables
34	fmt.Println("Tables in the in-memory database:")
35	for _, table := range tables {
36		fmt.Println(table)
37	}
38	// Print the content of the users table
39	userRows, err := memDb.Query("SELECT * FROM user")
40	if err != nil {
41		return err
42	}
43	defer userRows.Close()
44
45	fmt.Println("\nContent of the 'user' table:")
46	for userRows.Next() {
47		// Assuming users table has columns: id, name
48		var id int
49		var name string
50		if err := userRows.Scan(&id, &name); err != nil {
51			return err
52		}
53		fmt.Printf("ID: %d, Name: %s\n", id, name)
54	}
55
56	// Print the content of accounts table
57	accountRows, err := memDb.Query("SELECT * FROM account")
58	if err != nil {
59		return err
60	}
61
62	fmt.Println("\nContent of the 'account' table:")
63	for accountRows.Next() {
64		// Assuming accounts table has columns: id, name, user_id
65		var id int
66		var name string
67		var userID int
68		if err := accountRows.Scan(&id, &name, &userID); err != nil {
69			return err
70		}
71		fmt.Printf("ID: %d, Name: %s, UserID: %d\n", id, name, userID)
72	}
73
74	return nil
75}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close