File tree Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Original file line number Diff line number Diff line change @@ -147,21 +147,7 @@ const result = await db.selectFrom('users').select('name').executeTakeFirstOrThr
147147// 'James Smith'
148148```
149149
150- - In PowerSync
151-
152- ``` js
153- await powerSyncDb .writeTransaction ((transaction ) => {
154- await transaction .execute (' INSERT INTO users (id, name) VALUES(4, ?)' , [' James' ]);
155- await transaction .execute (" UPDATE users SET name = ? WHERE name = ?" , [' James Smith' , ' James' ]);
156- })
157- const result = await powerSyncDb .get (' SELECT name FROM users WHERE name = ?' , [' James Smith' ])
158-
159- // 'James Smith'
160- ```
161-
162- ### Transaction with raw SQL
163-
164- - In Kysely
150+ - In Kysely also using raw SQL
165151
166152``` js
167153await db .transaction ().execute (async (transaction ) => {
@@ -177,7 +163,7 @@ const result = await db.selectFrom('users').select('name').executeTakeFirstOrThr
177163
178164``` js
179165 await powerSyncDb .writeTransaction ((transaction ) => {
180- await sql ` INSERT INTO users (id, name) VALUES ( ' 4 ' , ' James' ); ` . execute (transaction)
166+ await transaction . execute ( ' INSERT INTO users (id, name) VALUES(4, ?) ' , [ ' James' ]);
181167 await transaction .execute (" UPDATE users SET name = ? WHERE name = ?" , [' James Smith' , ' James' ]);
182168 })
183169 const result = await powerSyncDb .get (' SELECT name FROM users WHERE name = ?' , [' James Smith' ])
You can’t perform that action at this time.
0 commit comments