feat: delete users - not tested
This commit is contained in:
@@ -26,12 +26,12 @@ export class UserPreferencesRepository {
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING *
|
||||
`;
|
||||
|
||||
|
||||
const values = [
|
||||
data.userId,
|
||||
data.unitSystem || 'imperial',
|
||||
(data as any).currencyCode || 'USD',
|
||||
(data as any).timeZone || 'UTC'
|
||||
data.currencyCode || 'USD',
|
||||
data.timeZone || 'UTC'
|
||||
];
|
||||
|
||||
const result = await this.db.query(query, values);
|
||||
@@ -47,13 +47,13 @@ export class UserPreferencesRepository {
|
||||
fields.push(`unit_system = $${paramCount++}`);
|
||||
values.push(data.unitSystem);
|
||||
}
|
||||
if ((data as any).currencyCode !== undefined) {
|
||||
if (data.currencyCode !== undefined) {
|
||||
fields.push(`currency_code = $${paramCount++}`);
|
||||
values.push((data as any).currencyCode);
|
||||
values.push(data.currencyCode);
|
||||
}
|
||||
if ((data as any).timeZone !== undefined) {
|
||||
if (data.timeZone !== undefined) {
|
||||
fields.push(`time_zone = $${paramCount++}`);
|
||||
values.push((data as any).timeZone);
|
||||
values.push(data.timeZone);
|
||||
}
|
||||
|
||||
if (fields.length === 0) {
|
||||
@@ -61,12 +61,12 @@ export class UserPreferencesRepository {
|
||||
}
|
||||
|
||||
const query = `
|
||||
UPDATE user_preferences
|
||||
UPDATE user_preferences
|
||||
SET ${fields.join(', ')}, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE user_id = $${paramCount}
|
||||
RETURNING *
|
||||
`;
|
||||
|
||||
|
||||
values.push(userId);
|
||||
const result = await this.db.query(query, values);
|
||||
return result.rows.length > 0 ? this.mapRow(result.rows[0]) : null;
|
||||
|
||||
@@ -18,6 +18,8 @@ export interface UserPreferences {
|
||||
export interface CreateUserPreferencesRequest {
|
||||
userId: string;
|
||||
unitSystem?: UnitSystem;
|
||||
currencyCode?: string;
|
||||
timeZone?: string;
|
||||
}
|
||||
|
||||
export interface UpdateUserPreferencesRequest {
|
||||
|
||||
Reference in New Issue
Block a user