refactor: adjust queries

This commit is contained in:
Mauricio Siu
2025-02-15 23:01:36 -06:00
parent 78c72b6337
commit 515d65d993
23 changed files with 538 additions and 138 deletions

View File

@@ -12,14 +12,14 @@ export type Bitbucket = typeof bitbucket.$inferSelect;
export const createBitbucket = async (
input: typeof apiCreateBitbucket._type,
userId: string,
organizationId: string,
) => {
return await db.transaction(async (tx) => {
const newGitProvider = await tx
.insert(gitProvider)
.values({
providerType: "bitbucket",
userId: userId,
organizationId: organizationId,
name: input.name,
})
.returning()
@@ -74,12 +74,12 @@ export const updateBitbucket = async (
.where(eq(bitbucket.bitbucketId, bitbucketId))
.returning();
if (input.name || input.userId) {
if (input.name || input.organizationId) {
await tx
.update(gitProvider)
.set({
name: input.name,
userId: input.userId,
organizationId: input.organizationId,
})
.where(eq(gitProvider.gitProviderId, input.gitProviderId))
.returning();