Skip to content

Commit dc32705

Browse files
author
Frank
committed
zen: remove unnecessary transactions
1 parent 1eaf5c3 commit dc32705

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/console/app/src/routes/workspace-picker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import "./workspace-picker.css"
1414
const getWorkspaces = query(async () => {
1515
"use server"
1616
return withActor(async () => {
17-
return Database.transaction((tx) =>
17+
return Database.use((tx) =>
1818
tx
1919
.select({
2020
id: WorkspaceTable.id,

packages/console/core/src/account.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export namespace Account {
1111
id: z.string().optional(),
1212
}),
1313
async (input) =>
14-
Database.transaction(async (tx) => {
14+
Database.use(async (tx) => {
1515
const id = input.id ?? Identifier.create("account")
1616
await tx.insert(AccountTable).values({
1717
id,
@@ -21,13 +21,12 @@ export namespace Account {
2121
)
2222

2323
export const fromID = fn(z.string(), async (id) =>
24-
Database.transaction(async (tx) => {
25-
return tx
24+
Database.use((tx) =>
25+
tx
2626
.select()
2727
.from(AccountTable)
2828
.where(eq(AccountTable.id, id))
29-
.execute()
30-
.then((rows) => rows[0])
31-
}),
29+
.then((rows) => rows[0]),
30+
),
3231
)
3332
}

packages/console/core/src/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export namespace Provider {
4747
}),
4848
async ({ provider }) => {
4949
Actor.assertAdmin()
50-
return Database.transaction((tx) =>
50+
Database.use((tx) =>
5151
tx
5252
.delete(ProviderTable)
5353
.where(and(eq(ProviderTable.provider, provider), eq(ProviderTable.workspaceID, Actor.workspace()))),

packages/console/function/src/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export default {
194194
// Get workspace
195195
await Actor.provide("account", { accountID, email }, async () => {
196196
await User.joinInvitedWorkspaces()
197-
const workspaces = await Database.transaction(async (tx) =>
197+
const workspaces = await Database.use((tx) =>
198198
tx
199199
.select({ id: WorkspaceTable.id })
200200
.from(WorkspaceTable)

0 commit comments

Comments
 (0)