Documentation
¶
Overview ¶
Package schema provides APOC schema management functions.
This package implements all apoc.schema.* functions for managing database schema, constraints, and indexes.
Index ¶
- Variables
- func Analyze() map[string]interface{}
- func Assert(indexes, constraints map[string]interface{}) map[string]interface{}
- func Compare(schema1, schema2 map[string]interface{}) map[string]interface{}
- func CreateConstraint(label string, properties []string, constraintType string) error
- func CreateExistsConstraint(label string, properties []string) error
- func CreateIndex(label string, properties []string) error
- func CreateNodeKeyConstraint(label string, properties []string) error
- func CreateUniqueConstraint(label string, properties []string) error
- func DropConstraint(label string, properties []string) error
- func DropIndex(label string, properties []string) error
- func Export() map[string]interface{}
- func Import(schemaDef map[string]interface{}) error
- func Info() map[string]interface{}
- func Labels() []string
- func NodeConstraintExists(label string, properties []string) bool
- func NodeIndexExists(label string, properties []string) bool
- func Nodes() []map[string]interface{}
- func Optimize() map[string]interface{}
- func Properties() []string
- func PropertiesDistinct(label string) []string
- func Relationships() []map[string]interface{}
- func Restore(snapshot map[string]interface{}) error
- func Snapshot() map[string]interface{}
- func Stats() map[string]interface{}
- func Types() []string
- func Validate() map[string]interface{}
- type ConstraintInfo
- type IndexInfo
- type Node
Constants ¶
This section is empty.
Variables ¶
var Storage storage.Storage = storage.NewInMemoryStorage()
Storage is the interface for database operations.
Functions ¶
func Analyze ¶
func Analyze() map[string]interface{}
Analyze analyzes schema usage.
Example:
apoc.schema.analyze() => analysis results
func Assert ¶
Assert creates or validates schema constraints.
Example:
apoc.schema.assert({Person: ['name']}, {Person: [['email']]})
func Compare ¶
Compare compares two schemas.
Example:
apoc.schema.compare(schema1, schema2) => differences
func CreateConstraint ¶
CreateConstraint creates a constraint.
Example:
apoc.schema.constraint.create('Person', ['email'], 'UNIQUE') => constraint created
func CreateExistsConstraint ¶
CreateExistsConstraint creates an exists constraint.
Example:
apoc.schema.constraint.exists('Person', ['name']) => constraint created
func CreateIndex ¶
CreateIndex creates an index.
Example:
apoc.schema.index.create('Person', ['name']) => index created
func CreateNodeKeyConstraint ¶
CreateNodeKeyConstraint creates a node key constraint.
Example:
apoc.schema.constraint.nodeKey('Person', ['id']) => constraint created
func CreateUniqueConstraint ¶
CreateUniqueConstraint creates a unique constraint.
Example:
apoc.schema.constraint.unique('Person', ['email']) => constraint created
func DropConstraint ¶
DropConstraint drops a constraint.
Example:
apoc.schema.constraint.drop('Person', ['email']) => constraint dropped
func DropIndex ¶
DropIndex drops an index.
Example:
apoc.schema.index.drop('Person', ['name']) => index dropped
func Export ¶
func Export() map[string]interface{}
Export exports schema definition.
Example:
apoc.schema.export() => schema definition
func Info ¶
func Info() map[string]interface{}
Info returns comprehensive schema information.
Example:
apoc.schema.info() => {labels: [...], types: [...], constraints: [...], indexes: [...]}
func Labels ¶
func Labels() []string
Labels returns all node labels.
Example:
apoc.schema.labels() => ['Person', 'Company', 'Product']
func NodeConstraintExists ¶
NodeConstraintExists checks if a constraint exists.
Example:
apoc.schema.node.constraintExists('Person', ['email']) => true/false
func NodeIndexExists ¶
NodeIndexExists checks if an index exists.
Example:
apoc.schema.node.indexExists('Person', ['name']) => true/false
func Nodes ¶
func Nodes() []map[string]interface{}
Nodes returns schema information for node labels.
Example:
apoc.schema.nodes() => [{label: 'Person', properties: [...]}]
func Optimize ¶
func Optimize() map[string]interface{}
Optimize optimizes schema.
Example:
apoc.schema.optimize() => optimization results
func Properties ¶
func Properties() []string
Properties returns all property keys in the database.
Example:
apoc.schema.properties.distinct() => ['name', 'age', 'email']
func PropertiesDistinct ¶
PropertiesDistinct returns distinct property keys.
Example:
apoc.schema.properties.distinct('Person') => ['name', 'age']
func Relationships ¶
func Relationships() []map[string]interface{}
Relationships returns schema information for relationship types.
Example:
apoc.schema.relationships() => [{type: 'KNOWS', properties: [...]}]
func Restore ¶
Restore restores from a schema snapshot.
Example:
apoc.schema.restore(snapshot) => restored
func Snapshot ¶
func Snapshot() map[string]interface{}
Snapshot creates a schema snapshot.
Example:
apoc.schema.snapshot() => snapshot
func Stats ¶
func Stats() map[string]interface{}
Stats returns schema statistics.
Example:
apoc.schema.stats() => {labelCount: 5, typeCount: 10, ...}
Types ¶
type ConstraintInfo ¶
ConstraintInfo represents constraint information.
func NodeConstraints ¶
func NodeConstraints() []*ConstraintInfo
NodeConstraints returns all node constraints.
Example:
apoc.schema.node.constraints() => constraint list
func RelationshipConstraints ¶
func RelationshipConstraints() []*ConstraintInfo
RelationshipConstraints returns all relationship constraints.
Example:
apoc.schema.relationship.constraints() => constraint list
type IndexInfo ¶
type IndexInfo struct {
Name string
Label string
Properties []string
Type string
State string
Unique bool
}
IndexInfo represents index information.
func NodeIndexes ¶
func NodeIndexes() []*IndexInfo
NodeIndexes returns all node indexes.
Example:
apoc.schema.node.indexes() => index list
func RelationshipIndexes ¶
func RelationshipIndexes() []*IndexInfo
RelationshipIndexes returns all relationship indexes.
Example:
apoc.schema.relationship.indexes() => index list