mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-14 23:09:07 +02:00
delete relationship
This commit is contained in:
@@ -1 +1,32 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph"
|
||||
)
|
||||
|
||||
func DelteRelationship(driver neo4j.DriverWithContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
var relationship memgraph.Relationship
|
||||
if err := c.ShouldBindJSON(&relationship); err != nil {
|
||||
log.Printf("ip: %s error: %s", c.ClientIP(), err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
err := relationship.DeleteRelationship(driver)
|
||||
if err != nil {
|
||||
log.Printf("ip: %s error: %s", c.ClientIP(), err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "internal server error"})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusAccepted, gin.H{"status": "relationship deleted successfully"})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user