forked from drizzle-team/drizzle-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SingleStore dialect * Add Durable Objects SQLite support * Bug fixes --------- Co-authored-by: Malone Hedges <[email protected]> Co-authored-by: Pedro Rodrigues <[email protected]> Co-authored-by: prodrigues <[email protected]> Co-authored-by: apeng-singlestore <[email protected]> Co-authored-by: Alex Blokh <[email protected]> Co-authored-by: Aleksandr Sherman <[email protected]> Co-authored-by: Sergey Reka <[email protected]>
- Loading branch information
1 parent
599da5e
commit 9cf0ed2
Showing
161 changed files
with
38,945 additions
and
780 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,40 @@ | ||
# New Dialects | ||
|
||
### 🎉 `SingleStore` dialect is now available in Drizzle | ||
|
||
Thanks to the SingleStore team for creating a PR with all the necessary changes to support the MySQL-compatible part of SingleStore. You can already start using it with Drizzle. The SingleStore team will also help us iterate through updates and make more SingleStore-specific features available in Drizzle | ||
|
||
```ts | ||
import 'dotenv/config'; | ||
import { defineConfig } from 'drizzle-kit'; | ||
|
||
export default defineConfig({ | ||
dialect: 'singlestore', | ||
out: './drizzle', | ||
schema: './src/db/schema.ts', | ||
dbCredentials: { | ||
url: process.env.DATABASE_URL!, | ||
}, | ||
}); | ||
``` | ||
|
||
You can check out our [Getting started guides](https://orm.drizzle.team/docs/get-started/singlestore-new) to try SingleStore! | ||
|
||
# New Drivers | ||
|
||
### 🎉 `SQLite Durable Objects` driver is now available in Drizzle | ||
|
||
You can now query SQLite Durable Objects in Drizzle! | ||
|
||
For the full example, please check our [Get Started](https://orm.drizzle.team/docs/get-started/do-new) Section | ||
|
||
```ts | ||
import 'dotenv/config'; | ||
import { defineConfig } from 'drizzle-kit'; | ||
export default defineConfig({ | ||
out: './drizzle', | ||
schema: './src/db/schema.ts', | ||
dialect: 'sqlite', | ||
driver: 'durable-sqlite', | ||
}); | ||
``` |
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
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,98 @@ | ||
# New Dialects | ||
|
||
### 🎉 `SingleStore` dialect is now available in Drizzle | ||
|
||
Thanks to the SingleStore team for creating a PR with all the necessary changes to support the MySQL-compatible part of SingleStore. You can already start using it with Drizzle. The SingleStore team will also help us iterate through updates and make more SingleStore-specific features available in Drizzle | ||
|
||
```ts | ||
import { int, singlestoreTable, varchar } from 'drizzle-orm/singlestore-core'; | ||
import { drizzle } from 'drizzle-orm/singlestore'; | ||
|
||
export const usersTable = singlestoreTable('users_table', { | ||
id: int().primaryKey(), | ||
name: varchar({ length: 255 }).notNull(), | ||
age: int().notNull(), | ||
email: varchar({ length: 255 }).notNull().unique(), | ||
}); | ||
|
||
... | ||
|
||
const db = drizzle(process.env.DATABASE_URL!); | ||
|
||
db.select()... | ||
``` | ||
|
||
You can check out our [Getting started guides](https://orm.drizzle.team/docs/get-started/singlestore-new) to try SingleStore! | ||
|
||
# New Drivers | ||
|
||
### 🎉 `SQLite Durable Objects` driver is now available in Drizzle | ||
|
||
You can now query SQLite Durable Objects in Drizzle! | ||
|
||
For the full example, please check our [Get Started](https://orm.drizzle.team/docs/get-started/do-new) Section | ||
|
||
```ts | ||
/// <reference types="@cloudflare/workers-types" /> | ||
import { drizzle, DrizzleSqliteDODatabase } from 'drizzle-orm/durable-sqlite'; | ||
import { DurableObject } from 'cloudflare:workers' | ||
import { migrate } from 'drizzle-orm/durable-sqlite/migrator'; | ||
import migrations from '../drizzle/migrations'; | ||
import { usersTable } from './db/schema'; | ||
|
||
export class MyDurableObject1 extends DurableObject { | ||
storage: DurableObjectStorage; | ||
db: DrizzleSqliteDODatabase<any>; | ||
|
||
constructor(ctx: DurableObjectState, env: Env) { | ||
super(ctx, env); | ||
this.storage = ctx.storage; | ||
this.db = drizzle(this.storage, { logger: false }); | ||
} | ||
|
||
async migrate() { | ||
migrate(this.db, migrations); | ||
} | ||
|
||
async insert(user: typeof usersTable.$inferInsert) { | ||
await this.db.insert(usersTable).values(user); | ||
} | ||
|
||
async select() { | ||
return this.db.select().from(usersTable); | ||
} | ||
} | ||
|
||
export default { | ||
/** | ||
* This is the standard fetch handler for a Cloudflare Worker | ||
* | ||
* @param request - The request submitted to the Worker from the client | ||
* @param env - The interface to reference bindings declared in wrangler.toml | ||
* @param ctx - The execution context of the Worker | ||
* @returns The response to be sent back to the client | ||
*/ | ||
async fetch(request: Request, env: Env): Promise<Response> { | ||
const id: DurableObjectId = env.MY_DURABLE_OBJECT1.idFromName('durable-object'); | ||
const stub = env.MY_DURABLE_OBJECT1.get(id); | ||
await stub.migrate(); | ||
|
||
await stub.insert({ | ||
name: 'John', | ||
age: 30, | ||
email: '[email protected]', | ||
}) | ||
console.log('New user created!') | ||
|
||
const users = await stub.select(); | ||
console.log('Getting all users from the database: ', users) | ||
|
||
return new Response(); | ||
} | ||
} | ||
``` | ||
|
||
# Bug fixes | ||
|
||
- [[BUG]: $with is undefined on withReplicas](https://github.com/drizzle-team/drizzle-orm/issues/1834) | ||
- [[BUG]: Neon serverless driver accepts authToken as a promise, but the $withAuth does not](https://github.com/drizzle-team/drizzle-orm/issues/3597) |
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
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
Oops, something went wrong.