I have a go project that connects to a postgres database. I want to delete orders over a certain number of days - I have tried doing it like this:
type SQLOrderDatabase struct {
Connection *pgx.Conn
logger *logrus.Entry
}
interval := pgtype.Interval{}
_ = interval.Set(time.Second * 5)
_, err := database.Connection.Exec(ctx, "DELETE FROM store.items WHERE store.time > (now() AT TIME ZONE 'utc' - $1);", &interval)
This is using the pgx library and pgx types. However it consistently fails with this error:
Error:ERROR: operator does not exist: timestamp without time zone \u003e interval (SQLSTATE 42883)","severity":"error","
Is there anyway to use postgres intervals with go?