MCPcopy
hub / github.com/pocketbase/pocketbase / TableIndexes

Method TableIndexes

core/db_table.go:56–81  ·  view source on GitHub ↗

TableIndexes returns a name grouped map with all non empty index of the specified table. Note: This method doesn't return an error on nonexisting table.

(tableName string)

Source from the content-addressed store, hash-verified

54//
55// Note: This method doesn't return an error on nonexisting table.
56func (app *BaseApp) TableIndexes(tableName string) (map[string]string, error) {
57 indexes := []struct {
58 Name string
59 Sql string
60 }{}
61
62 err := app.ConcurrentDB().Select("name", "sql").
63 From("sqlite_master").
64 AndWhere(dbx.NewExp("sql is not null")).
65 AndWhere(dbx.HashExp{
66 "type": "index",
67 "tbl_name": tableName,
68 }).
69 All(&indexes)
70 if err != nil {
71 return nil, err
72 }
73
74 result := make(map[string]string, len(indexes))
75
76 for _, idx := range indexes {
77 result[idx.Name] = idx.Sql
78 }
79
80 return result, nil
81}
82
83// DeleteTable drops the specified table.
84//

Callers

nothing calls this directly

Calls 2

ConcurrentDBMethod · 0.95
SelectMethod · 0.80

Tested by

no test coverage detected