Skip to content

Commit

Permalink
finishing the entity tag implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Dec 20, 2024
1 parent a147319 commit 6976eb4
Show file tree
Hide file tree
Showing 7 changed files with 525 additions and 118 deletions.
15 changes: 15 additions & 0 deletions migrations/neo4j/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ func InitializeSchema(driver neo4jdb.DriverWithContext, dbname string) error {
return err
}

err = executeQuery(driver, dbname, "CREATE INDEX entities_range_index_etype IF NOT EXISTS FOR (n:Entity) ON (n.etype)")
if err != nil {
return err
}

err = executeQuery(driver, dbname, "CREATE INDEX entities_range_index_updated_at IF NOT EXISTS FOR (n:Entity) ON (n.updated_at)")
if err != nil {
return err
Expand All @@ -29,6 +34,11 @@ func InitializeSchema(driver neo4jdb.DriverWithContext, dbname string) error {
return err
}

err = executeQuery(driver, dbname, "CREATE INDEX enttag_range_index_ttype IF NOT EXISTS FOR (n:EntityTag) ON (n.ttype)")
if err != nil {
return err
}

err = executeQuery(driver, dbname, "CREATE INDEX enttag_range_index_updated_at IF NOT EXISTS FOR (n:EntityTag) ON (n.updated_at)")
if err != nil {
return err
Expand All @@ -44,6 +54,11 @@ func InitializeSchema(driver neo4jdb.DriverWithContext, dbname string) error {
return err
}

err = executeQuery(driver, dbname, "CREATE INDEX edgetag_range_index_ttype IF NOT EXISTS FOR (n:EdgeTag) ON (n.ttype)")
if err != nil {
return err
}

err = executeQuery(driver, dbname, "CREATE INDEX edgetag_range_index_updated_at IF NOT EXISTS FOR (n:EdgeTag) ON (n.updated_at)")
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions repository/neo4j/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ func (neo *neoRepository) DeleteEntity(id string) error {
defer cancel()

_, err := neo4jdb.ExecuteQuery(ctx, neo.db,
"MATCH (n:Entity {entity_id: $entity_id}) DETACH DELETE n",
"MATCH (n:Entity {entity_id: $eid}) DETACH DELETE n",
map[string]interface{}{
"entity_id": id,
"eid": id,
},
neo4jdb.EagerResultTransformer,
neo4jdb.ExecuteQueryWithDatabase(neo.dbname),
Expand Down
Loading

0 comments on commit 6976eb4

Please sign in to comment.