how to create constraints
CREATE CONSTRAINT ON (person:Person) ASSERT person.id IS UNIQUE;
Is there a way to create constraints like this om AGE ? If there is, sorry since I can't find documentation about it, would appreciate if you can point out
Hello, we are aware of this syntax, though is not yet implemented. Thanks for your interest.
Hi, thanks. So how are constraints created ? Is this possible ? The thing is, I can't find anything in the docs
@JourneyToSilius, have you figured out how to apply constraints in the graph?
I'm just now starting to exploring this.
@NathanFrund here is a demo implementation of how I did it in Go:
func (s *store) CreateUniquePropertyFunction() error {
queryFormat := `CREATE OR REPLACE FUNCTION graph.aggregated.get_vertex_address(properties agtype)
RETURNS agtype
AS
$BODY$
SELECT graph.ag_catalog.agtype_access_operator($1, '"address"');
$BODY$
LANGUAGE sql
IMMUTABLE;`
_, err := s.AgePoolConnector.Pool.Exec(context.Background(), queryFormat)
if err != nil {
return fmt.Errorf("failed to execute query: %v", err)
}
return nil
}
func (s *store) CreateUniqueVertexConstraint() error {
queryFormat := `CREATE UNIQUE INDEX idx_v2vertex_address_constraint ON graph.aggregated.v2vertex(get_vertex_address(properties));`
_, err := s.AgePoolConnector.Pool.Exec(context.Background(), queryFormat)
if err != nil {
return handleQueryError(err)
}
return nil
}