MCPcopy
hub / github.com/pocketbase/pocketbase / TableInfo

Method TableInfo

core/db_table.go:34–51  ·  view source on GitHub ↗

TableInfo returns the "table_info" pragma result for the specified table.

(tableName string)

Source from the content-addressed store, hash-verified

32
33// TableInfo returns the "table_info" pragma result for the specified table.
34func (app *BaseApp) TableInfo(tableName string) ([]*TableInfoRow, error) {
35 info := []*TableInfoRow{}
36
37 err := app.ConcurrentDB().NewQuery("SELECT * FROM PRAGMA_TABLE_INFO({:tableName})").
38 Bind(dbx.Params{"tableName": tableName}).
39 All(&info)
40 if err != nil {
41 return nil, err
42 }
43
44 // mattn/go-sqlite3 doesn't throw an error on invalid or missing table
45 // so we additionally have to check whether the loaded info result is nonempty
46 if len(info) == 0 {
47 return nil, fmt.Errorf("empty table info probably due to invalid or missing table %s", tableName)
48 }
49
50 return info, nil
51}
52
53// TableIndexes returns a name grouped map with all non empty index of the specified table.
54//

Callers

nothing calls this directly

Calls 3

ConcurrentDBMethod · 0.95
NewQueryMethod · 0.80
BindMethod · 0.45

Tested by

no test coverage detected