drizzle-team/drizzle-orm (drizzle-kit)
### [`v0.26.2`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.26.2)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.26.1...drizzle-kit@0.26.2)
- 🐛 Fixed upsert targeting composite keys for SQLite ([#521](https://redirect.github.com/drizzle-team/drizzle-orm/issues/521))
- 🐛 AWS Data API+Postgres: fixed adding of typings when merging queries ([#517](https://redirect.github.com/drizzle-team/drizzle-orm/issues/517))
- 🐛 Fixed "on conflict" with "where" clause for Postgres ([#651](https://redirect.github.com/drizzle-team/drizzle-orm/issues/651))
- 🐛 Various GitHub docs community fixes and improvements ♥ ([#547](https://redirect.github.com/drizzle-team/drizzle-orm/issues/547), [#548](https://redirect.github.com/drizzle-team/drizzle-orm/issues/548), [#587](https://redirect.github.com/drizzle-team/drizzle-orm/issues/587), [#606](https://redirect.github.com/drizzle-team/drizzle-orm/issues/606), [#609](https://redirect.github.com/drizzle-team/drizzle-orm/issues/609), [#625](https://redirect.github.com/drizzle-team/drizzle-orm/issues/625))
- **Experimental**: added OpenTelemetry support for Postgres
### [`v0.26.1`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.26.1)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.26.0...drizzle-kit@0.26.1)
- 🐛 Fixed including multiple relations on the same level in RQB ([#599](https://redirect.github.com/drizzle-team/drizzle-orm/issues/599))
- 🐛 Updated migrators for relational queries support ([#601](https://redirect.github.com/drizzle-team/drizzle-orm/issues/601))
- 🐛 Fixed invoking .findMany() without arguments
### [`v0.26.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.26.0)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.25.0...drizzle-kit@0.26.0)
### Drizzle ORM 0.26.0 is here 🎉
#### README docs are fully transferred to web
The documentation has been completely reworked and updated with additional examples and explanations. You can find it here: https://orm.drizzle.team.
Furthermore, the entire documentation has been made open source, allowing you to edit and add any information you deem important for the community.
Visit https://github.com/drizzle-team/drizzle-orm-docs to access the open-sourced documentation.
Additionally, you can create specific documentation issues in this repository
#### New Features
Introducing our first helper built on top of Drizzle Core API syntax: **the Relational Queries!** 🎉
With Drizzle RQ you can do:
1. Any amount of relations that will be mapped for you
2. Including or excluding! specific columns. You can also combine these options
3. Harness the flexibility of the `where` statements, allowing you to define custom conditions beyond the predefined ones available in the Drizzle Core API.
4. Expand the functionality by incorporating additional extras columns using SQL templates. For more examples, refer to the documentation.
Most importantly, regardless of the size of your query, Drizzle will always generate a **SINGLE optimized query**.
This efficiency extends to the usage of **Prepared Statements**, which are fully supported within the Relational Query Builder.
For more info: [Prepared Statements in Relational Query Builder](https://orm.drizzle.team/rqb#prepared-statements)
**Example of setting one-to-many relations**
> As you can observe, `relations` are a distinct concept that coexists alongside the main Drizzle schema. You have the flexibility to opt-in or opt-out of them at any time without affecting the `drizzle-kit` migrations or the logic for Core API's types and runtime.
```ts
import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core';
import { relations } from 'drizzle-orm';
export const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});
export const usersConfig = relations(users, ({ many }) => ({
posts: many(posts),
}));
export const posts = pgTable('posts', {
id: serial('id').primaryKey(),
content: text('content').notNull(),
authorId: integer('author_id').notNull(),
});
export const postsConfig = relations(posts, ({ one }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
}));
```
**Example of querying you database**
Step 1: Provide all tables and relations to `drizzle` function
> `drizzle` import depends on the database driver you're using
```ts
import * as schema from './schema';
import { drizzle } from 'drizzle-orm/...';
const db = drizzle(client, { schema });
await db.query.users.findMany(...);
```
If you have schema in multiple files
```ts
import * as schema1 from './schema1';
import * as schema2 from './schema2';
import { drizzle } from 'drizzle-orm/...';
const db = drizzle(client, { schema: { ...schema1, ...schema2 } });
await db.query.users.findMany(...);
```
Step 2: Query your database with Relational Query Builder
**Select all users**
```ts
const users = await db.query.users.findMany();
```
**Select first users**
> `.findFirst()` will add limit 1 to the query
```ts
const user = await db.query.users.findFirst();
```
**Select all users**
Get all posts with just `id`, `content` and include `comments`
```ts
const posts = await db.query.posts.findMany({
columns: {
id: true,
content: true,
},
with: {
comments: true,
}
});
```
**Select all posts excluding `content` column**
```ts
const posts = await db.query.posts.findMany({
columns: {
content: false,
},
});
```
For more examples you can check [full docs](https://orm.drizzle.team/rqb) for Relational Queries
#### Bug fixes
- 🐛 Fixed partial joins with prefixed tables ([#542](https://redirect.github.com/drizzle-team/drizzle-orm/issues/542))
#### Drizzle Kit updates
##### New ways to define drizzle config file
You can now specify the configuration not only in the `.json` format but also in `.ts` and `.js` formats.
**TypeScript example**
```ts
import { Config } from "drizzle-kit";
export default {
schema: "",
connectionString: process.env.DB_URL,
out: "",
breakpoints: true
} satisfies Config;
```
**JavaScript example**
```js
/** @type { import("drizzle-kit").Config } */
export default {
schema: "",
connectionString: "",
out: "",
breakpoints: true
};
```
#### New commands 🎉
##### `drizzle-kit push:mysql`
You can now push your MySQL schema directly to the database without the need to create and manage migration files. This feature proves to be particularly useful for rapid local development and when working with PlanetScale databases.
By pushing the MySQL schema directly to the database, you can streamline the development process and avoid the overhead of managing migration files. This allows for more efficient iteration and quick deployment of schema changes during local development.
##### How to setup your codebase for drizzle-kit push feature?
1. For this feature, you need to create a `drizzle.config.[ts|js|json]` file. We recommend using `.ts` or `.js` files as they allow you to easily provide the database connection information as secret variables
You'll need to specify `schema` and `connectionString`(or `db`, `port`, `host`, `password`, etc.) to make `drizzle-kit push:mysql` work
`drizzle.config.ts` example
```ts copy
import { Config } from "src";
export default {
schema: "./schema.ts",
connectionString: process.env.DB_URL,
} satisfies Config;
```
2. Run `drizzle-kit push:mysql`
3. If Drizzle detects any potential `data-loss` issues during a migration, it will prompt you to approve whether the data should be truncated or not in order to ensure a successful migration
4. Approve or reject the action that Drizzle needs to perform in order to push your schema changes to the database.
5. Done ✅
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
^0.25.0
->^0.26.2
Release Notes
drizzle-team/drizzle-orm (drizzle-kit)
### [`v0.26.2`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.26.2) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.26.1...drizzle-kit@0.26.2) - 🐛 Fixed upsert targeting composite keys for SQLite ([#521](https://redirect.github.com/drizzle-team/drizzle-orm/issues/521)) - 🐛 AWS Data API+Postgres: fixed adding of typings when merging queries ([#517](https://redirect.github.com/drizzle-team/drizzle-orm/issues/517)) - 🐛 Fixed "on conflict" with "where" clause for Postgres ([#651](https://redirect.github.com/drizzle-team/drizzle-orm/issues/651)) - 🐛 Various GitHub docs community fixes and improvements ♥ ([#547](https://redirect.github.com/drizzle-team/drizzle-orm/issues/547), [#548](https://redirect.github.com/drizzle-team/drizzle-orm/issues/548), [#587](https://redirect.github.com/drizzle-team/drizzle-orm/issues/587), [#606](https://redirect.github.com/drizzle-team/drizzle-orm/issues/606), [#609](https://redirect.github.com/drizzle-team/drizzle-orm/issues/609), [#625](https://redirect.github.com/drizzle-team/drizzle-orm/issues/625)) - **Experimental**: added OpenTelemetry support for Postgres ### [`v0.26.1`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.26.1) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.26.0...drizzle-kit@0.26.1) - 🐛 Fixed including multiple relations on the same level in RQB ([#599](https://redirect.github.com/drizzle-team/drizzle-orm/issues/599)) - 🐛 Updated migrators for relational queries support ([#601](https://redirect.github.com/drizzle-team/drizzle-orm/issues/601)) - 🐛 Fixed invoking .findMany() without arguments ### [`v0.26.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.26.0) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.25.0...drizzle-kit@0.26.0) ### Drizzle ORM 0.26.0 is here 🎉 #### README docs are fully transferred to web The documentation has been completely reworked and updated with additional examples and explanations. You can find it here: https://orm.drizzle.team. Furthermore, the entire documentation has been made open source, allowing you to edit and add any information you deem important for the community. Visit https://github.com/drizzle-team/drizzle-orm-docs to access the open-sourced documentation. Additionally, you can create specific documentation issues in this repository #### New Features Introducing our first helper built on top of Drizzle Core API syntax: **the Relational Queries!** 🎉 With Drizzle RQ you can do: 1. Any amount of relations that will be mapped for you 2. Including or excluding! specific columns. You can also combine these options 3. Harness the flexibility of the `where` statements, allowing you to define custom conditions beyond the predefined ones available in the Drizzle Core API. 4. Expand the functionality by incorporating additional extras columns using SQL templates. For more examples, refer to the documentation. Most importantly, regardless of the size of your query, Drizzle will always generate a **SINGLE optimized query**. This efficiency extends to the usage of **Prepared Statements**, which are fully supported within the Relational Query Builder. For more info: [Prepared Statements in Relational Query Builder](https://orm.drizzle.team/rqb#prepared-statements) **Example of setting one-to-many relations** > As you can observe, `relations` are a distinct concept that coexists alongside the main Drizzle schema. You have the flexibility to opt-in or opt-out of them at any time without affecting the `drizzle-kit` migrations or the logic for Core API's types and runtime. ```ts import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; export const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name').notNull(), }); export const usersConfig = relations(users, ({ many }) => ({ posts: many(posts), })); export const posts = pgTable('posts', { id: serial('id').primaryKey(), content: text('content').notNull(), authorId: integer('author_id').notNull(), }); export const postsConfig = relations(posts, ({ one }) => ({ author: one(users, { fields: [posts.authorId], references: [users.id] }), })); ``` **Example of querying you database** Step 1: Provide all tables and relations to `drizzle` function > `drizzle` import depends on the database driver you're using ```ts import * as schema from './schema'; import { drizzle } from 'drizzle-orm/...'; const db = drizzle(client, { schema }); await db.query.users.findMany(...); ``` If you have schema in multiple files ```ts import * as schema1 from './schema1'; import * as schema2 from './schema2'; import { drizzle } from 'drizzle-orm/...'; const db = drizzle(client, { schema: { ...schema1, ...schema2 } }); await db.query.users.findMany(...); ``` Step 2: Query your database with Relational Query Builder **Select all users** ```ts const users = await db.query.users.findMany(); ``` **Select first users** > `.findFirst()` will add limit 1 to the query ```ts const user = await db.query.users.findFirst(); ``` **Select all users** Get all posts with just `id`, `content` and include `comments` ```ts const posts = await db.query.posts.findMany({ columns: { id: true, content: true, }, with: { comments: true, } }); ``` **Select all posts excluding `content` column** ```ts const posts = await db.query.posts.findMany({ columns: { content: false, }, }); ``` For more examples you can check [full docs](https://orm.drizzle.team/rqb) for Relational Queries #### Bug fixes - 🐛 Fixed partial joins with prefixed tables ([#542](https://redirect.github.com/drizzle-team/drizzle-orm/issues/542)) #### Drizzle Kit updates ##### New ways to define drizzle config file You can now specify the configuration not only in the `.json` format but also in `.ts` and `.js` formats. **TypeScript example** ```ts import { Config } from "drizzle-kit"; export default { schema: "", connectionString: process.env.DB_URL, out: "", breakpoints: true } satisfies Config; ``` **JavaScript example** ```js /** @type { import("drizzle-kit").Config } */ export default { schema: "", connectionString: "", out: "", breakpoints: true }; ``` #### New commands 🎉 ##### `drizzle-kit push:mysql` You can now push your MySQL schema directly to the database without the need to create and manage migration files. This feature proves to be particularly useful for rapid local development and when working with PlanetScale databases. By pushing the MySQL schema directly to the database, you can streamline the development process and avoid the overhead of managing migration files. This allows for more efficient iteration and quick deployment of schema changes during local development. ##### How to setup your codebase for drizzle-kit push feature? 1. For this feature, you need to create a `drizzle.config.[ts|js|json]` file. We recommend using `.ts` or `.js` files as they allow you to easily provide the database connection information as secret variables You'll need to specify `schema` and `connectionString`(or `db`, `port`, `host`, `password`, etc.) to make `drizzle-kit push:mysql` work `drizzle.config.ts` example ```ts copy import { Config } from "src"; export default { schema: "./schema.ts", connectionString: process.env.DB_URL, } satisfies Config; ``` 2. Run `drizzle-kit push:mysql` 3. If Drizzle detects any potential `data-loss` issues during a migration, it will prompt you to approve whether the data should be truncated or not in order to ensure a successful migration 4. Approve or reject the action that Drizzle needs to perform in order to push your schema changes to the database. 5. Done ✅Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.