Spaces:
Sleeping
Sleeping
Download src/libs/shared/infrastructure/postgres/repositories/PgOrganizationRepository.ts from fouadkhalid123/asd: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/libs/shared/infrastructure/postgres/repositories/PgOrganizationRepository.ts
- Command line
-
hf download hf://spaces/fouadkhalid123/asd/src/libs/shared/infrastructure/postgres/repositories/PgOrganizationRepository.ts
-
curl -L -o PgOrganizationRepository.ts https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/libs/shared/infrastructure/postgres/repositories/PgOrganizationRepository.ts
1.06 kB
| import { eq } from "drizzle-orm"; | |
| import { organizations, Organization, NewOrganization } from "../schema/organizations"; | |
| import { IPgOrganizationRepository } from "./IPgOrganizationRepository"; | |
| export class PgOrganizationRepository implements IPgOrganizationRepository { | |
| constructor(private readonly db: any) { } | |
| async upsert(input: NewOrganization): Promise<Organization> { | |
| const [result] = await this.db | |
| .insert(organizations) | |
| .values(input) | |
| .onConflictDoUpdate({ | |
| target: [organizations.id], | |
| set: { | |
| updatedAt: new Date(), | |
| }, | |
| }) | |
| .returning(); | |
| return result; | |
| } | |
| async findById(id: string): Promise<Organization | null> { | |
| const [result] = await this.db.select().from(organizations).where(eq(organizations.id, id)).limit(1); | |
| return result || null; | |
| } | |
| async delete(id: string): Promise<void> { | |
| await this.db.delete(organizations).where(eq(organizations.id, id)); | |
| } | |
| } | |