January 2020
Intermediate to advanced
640 pages
16h 56m
English
The last piece of functionality that we will be examining is the RemoveStaleEdges method, which uses the following query to delete edges that have not been updated after a particular point in time:
DELETE FROM edges WHERE src=$1 AND updated_at < $2
Let's take a look at the RemoveStaleEdges method implementation:
func (c *CockroachDBGraph) RemoveStaleEdges(fromID uuid.UUID, updatedBefore time.Time) error { _, err := c.db.Exec(removeStaleEdgesQuery, fromID, updatedBefore.UTC()) if err != nil { return xerrors.Errorf("remove stale edges: %w", err) } return nil }
There' nothing out of the ordinary here; the code in the preceding snippet simply binds the arguments to the delete query and executes it.