-
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@effect/sql-sqlite-react-native": patch | ||
"@effect/sql-sqlite-node": patch | ||
"@effect/sql-sqlite-wasm": patch | ||
"@effect/sql-sqlite-bun": patch | ||
"@effect/sql-mysql2": patch | ||
"@effect/sql-mssql": patch | ||
"@effect/sql-pg": patch | ||
"@effect/sql": patch | ||
--- | ||
|
||
add .returning helper to insert and update apis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
"@effect/sql-sqlite-react-native": minor | ||
"@effect/sql-sqlite-node": minor | ||
"@effect/sql-sqlite-wasm": minor | ||
"@effect/sql-sqlite-bun": minor | ||
"@effect/sql-mysql2": minor | ||
"@effect/sql-mssql": minor | ||
"@effect/sql-pg": minor | ||
"@effect/sql": minor | ||
--- | ||
|
||
make @effect/sql dialect agnostic | ||
|
||
All of the client implementations now share the same Context.Tag. This means you can create | ||
services that support multiple SQL flavors. | ||
|
||
You can now use the `@effect/sql` package to access the client apis: | ||
|
||
```ts | ||
import * as Sql from "@effect/sql" | ||
import { Effect } from "effect" | ||
|
||
Effect.gen(function* () { | ||
const sql = yield* Sql.client.Client | ||
yield* sql`SELECT * FROM users` | ||
}) | ||
``` | ||
|
||
If you need a functionality that is specific to a implementation, you can use the tag from the | ||
implementation package: | ||
|
||
```ts | ||
import * as Sqlite from "@effect/sql-sqlite-node" | ||
import { Effect } from "effect" | ||
|
||
Effect.gen(function* () { | ||
const sql = yield* Sqlite.client.SqliteClient | ||
const dump = yield* sql.export | ||
}) | ||
``` | ||
|
||
If you need to run a different query depending on the dialect, you can use the `sql.onDialect` api: | ||
|
||
```ts | ||
import * as Sql from "@effect/sql" | ||
import { Effect } from "effect" | ||
|
||
Effect.gen(function* () { | ||
const sql = yield* Sql.client.Client | ||
yield* sql.onDialect({ | ||
sqlite: sql`SELECT * FROM sqlite_master`, | ||
mysql: sql`SHOW TABLES`, | ||
mssql: sql`SELECT * FROM sys.tables`, | ||
pg: sql`SELECT * FROM pg_catalog.pg_tables` | ||
}) | ||
}) | ||
``` |