MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / createIndexQuery

Function createIndexQuery

plugins/destination/neo4j/client/migrate.go:76–99  ·  view source on GitHub ↗
(table *schema.Table)

Source from the content-addressed store, hash-verified

74}
75
76func createIndexQuery(table *schema.Table) string {
77 pks := table.PrimaryKeys()
78 if len(pks) == 0 {
79 // empty query = no need to do anything
80 return ""
81 }
82
83 var sb strings.Builder
84 sb.WriteString(`CREATE INDEX `)
85 sb.WriteString(indexName(table))
86 sb.WriteString(` IF NOT EXISTS FOR (n:`)
87 sb.WriteString(table.Name)
88 sb.WriteString(`) ON (`)
89 for i, name := range pks {
90 if i != 0 {
91 sb.WriteString(`, `)
92 }
93 sb.WriteString(`n.`)
94 sb.WriteString(name)
95 }
96 sb.WriteString(`);`)
97
98 return sb.String()
99}
100
101func indexName(table *schema.Table) string {
102 return `_cq_index_` + table.Name

Callers 1

tryCreateIndexMethod · 0.85

Calls 2

indexNameFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected