| 2039 | } |
| 2040 | |
| 2041 | func (dbResource *DbResource) GetUserEmailByIdWithTransaction(userId int64, transaction *sqlx.Tx) string { |
| 2042 | s, q, err := statementbuilder.Squirrel.Select("email").Prepared(true). |
| 2043 | From(USER_ACCOUNT_TABLE_NAME).Where(goqu.Ex{"id": userId}).ToSQL() |
| 2044 | if err != nil { |
| 2045 | log.Errorf("failed to create email lookup query: %v", err) |
| 2046 | return "" |
| 2047 | } |
| 2048 | stmt1, err := transaction.Preparex(s) |
| 2049 | if err != nil { |
| 2050 | log.Errorf("failed to prepare email lookup statement: %v", err) |
| 2051 | return "" |
| 2052 | } |
| 2053 | defer stmt1.Close() |
| 2054 | var email string |
| 2055 | err = stmt1.QueryRowx(q...).Scan(&email) |
| 2056 | if err != nil { |
| 2057 | log.Warnf("failed to get email for user_account_id %d: %v", userId, err) |
| 2058 | return "" |
| 2059 | } |
| 2060 | return email |
| 2061 | } |
| 2062 | |
| 2063 | func (dbResource *DbResource) GetSingleRowByReferenceIdWithTransaction(typeName string, referenceId daptinid.DaptinReferenceId, |
| 2064 | includedRelations map[string]bool, transaction *sqlx.Tx) (map[string]interface{}, []map[string]interface{}, error) { |