From 18eedaa62f6e0b55b79c77829301daaace4d90f3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 12 May 2022 12:31:25 -0400 Subject: [PATCH] satellite/satellitedb/dbx: add method to delete webapp sessions by user ID Change-Id: I4552622fdf40c6ecd53046e597250bbe713f510c --- satellite/satellitedb/dbx/satellitedb.dbx | 1 + satellite/satellitedb/dbx/satellitedb.dbx.go | 69 ++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/satellite/satellitedb/dbx/satellitedb.dbx b/satellite/satellitedb/dbx/satellitedb.dbx index 77acfc6b8..fe202b548 100644 --- a/satellite/satellitedb/dbx/satellitedb.dbx +++ b/satellite/satellitedb/dbx/satellitedb.dbx @@ -358,6 +358,7 @@ model webapp_session ( create webapp_session ( ) update webapp_session ( where webapp_session.id = ? ) delete webapp_session ( where webapp_session.id = ? ) +delete webapp_session ( where webapp_session.user_id = ? ) read all ( select webapp_session diff --git a/satellite/satellitedb/dbx/satellitedb.dbx.go b/satellite/satellitedb/dbx/satellitedb.dbx.go index c6839837b..ebc3e6623 100644 --- a/satellite/satellitedb/dbx/satellitedb.dbx.go +++ b/satellite/satellitedb/dbx/satellitedb.dbx.go @@ -16853,6 +16853,33 @@ func (obj *pgxImpl) Delete_WebappSession_By_Id(ctx context.Context, } +func (obj *pgxImpl) Delete_WebappSession_By_UserId(ctx context.Context, + webapp_session_user_id WebappSession_UserId_Field) ( + count int64, err error) { + defer mon.Task()(&ctx)(&err) + + var __embed_stmt = __sqlbundle_Literal("DELETE FROM webapp_sessions WHERE webapp_sessions.user_id = ?") + + var __values []interface{} + __values = append(__values, webapp_session_user_id.value()) + + var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt) + obj.logStmt(__stmt, __values...) + + __res, err := obj.driver.ExecContext(ctx, __stmt, __values...) + if err != nil { + return 0, obj.makeErr(err) + } + + count, err = __res.RowsAffected() + if err != nil { + return 0, obj.makeErr(err) + } + + return count, nil + +} + func (obj *pgxImpl) Delete_Project_By_Id(ctx context.Context, project_id Project_Id_Field) ( deleted bool, err error) { @@ -23420,6 +23447,33 @@ func (obj *pgxcockroachImpl) Delete_WebappSession_By_Id(ctx context.Context, } +func (obj *pgxcockroachImpl) Delete_WebappSession_By_UserId(ctx context.Context, + webapp_session_user_id WebappSession_UserId_Field) ( + count int64, err error) { + defer mon.Task()(&ctx)(&err) + + var __embed_stmt = __sqlbundle_Literal("DELETE FROM webapp_sessions WHERE webapp_sessions.user_id = ?") + + var __values []interface{} + __values = append(__values, webapp_session_user_id.value()) + + var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt) + obj.logStmt(__stmt, __values...) + + __res, err := obj.driver.ExecContext(ctx, __stmt, __values...) + if err != nil { + return 0, obj.makeErr(err) + } + + count, err = __res.RowsAffected() + if err != nil { + return 0, obj.makeErr(err) + } + + return count, nil + +} + func (obj *pgxcockroachImpl) Delete_Project_By_Id(ctx context.Context, project_id Project_Id_Field) ( deleted bool, err error) { @@ -24980,6 +25034,17 @@ func (rx *Rx) Delete_WebappSession_By_Id(ctx context.Context, return tx.Delete_WebappSession_By_Id(ctx, webapp_session_id) } +func (rx *Rx) Delete_WebappSession_By_UserId(ctx context.Context, + webapp_session_user_id WebappSession_UserId_Field) ( + count int64, err error) { + var tx *Tx + if tx, err = rx.getTx(ctx); err != nil { + return + } + return tx.Delete_WebappSession_By_UserId(ctx, webapp_session_user_id) + +} + func (rx *Rx) Find_AccountingTimestamps_Value_By_Name(ctx context.Context, accounting_timestamps_name AccountingTimestamps_Name_Field) ( row *Value_Row, err error) { @@ -26259,6 +26324,10 @@ type Methods interface { webapp_session_id WebappSession_Id_Field) ( deleted bool, err error) + Delete_WebappSession_By_UserId(ctx context.Context, + webapp_session_user_id WebappSession_UserId_Field) ( + count int64, err error) + Find_AccountingTimestamps_Value_By_Name(ctx context.Context, accounting_timestamps_name AccountingTimestamps_Name_Field) ( row *Value_Row, err error)