Skip to content

Commit

Permalink
unused
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Jan 17, 2025
1 parent bf689d0 commit de1eb9d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
35 changes: 0 additions & 35 deletions packages/services/storage/src/db/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,6 @@ export function createConnectionString(config: {
return `postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.db}${config.ssl ? '?sslmode=require' : '?sslmode=disable'}`;
}

export function objectToParams<T extends Record<string, any>>(
obj: T,
transformArray?: <K extends keyof T>(key: K, value: T[K]) => any,
) {
const identifiers = sql.join(
Object.keys(obj).map(k => sql.identifier([k])),
sql`, `,
);

const values = sql.join(
Object.keys(obj).map(key => {
if (obj[key] === undefined || obj[key] === null) {
return null;
}
if (Array.isArray(obj[key])) {
return transformArray!(key, obj[key] as any);
}
if (typeof obj[key] === 'object') {
return sql.json(obj[key]);
}
return obj[key];
}),
sql`, `,
);

return { identifiers, values };
}

export function objectToUpdateParams(obj: Record<string, any>) {
return sql.join(
Object.keys(obj).map(key => sql`${sql.identifier([key])} = ${obj[key]}`),
sql`, `,
);
}

export function toDate(date: Date) {
return sql`to_timestamp(${date.getTime() / 1000})`;
}
1 change: 0 additions & 1 deletion packages/services/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
alert_channels,
alerts,
getPool,
objectToParams,
organization_invitations,
organization_member,
organization_member_roles,
Expand Down

0 comments on commit de1eb9d

Please sign in to comment.