drizzle-team / drizzle-orm-docs Goto Github PK
View Code? Open in Web Editor NEWDrizzle ORM documentation website
Home Page: https://orm.drizzle.team
Drizzle ORM documentation website
Home Page: https://orm.drizzle.team
The following works but isn't documented :
await db.insert(users)
.values({ firstName: 'John', lastName: 'Doe' })
.onConflictDoUpdate({
target: [users.firstName, users.lastName],
set: { firstName: 'John1' },
});
For example, on this page:
https://orm.drizzle.team/docs/indexes-constraints
If I choose "MySQL" for any of the code segments, I would want the rest of the code segments on the page to have "MySQL" chosen as well. And if I change that at any point on the page, it should change everywhere on the page.
It would also be nice to have this persist across the whole documentation site, but that's less necessary IMO.
visit https://orm.drizzle.team/docs/rqb#one-to-one & search for fields: [user.id]
it should be fields: [users.id]
Following the discussion given here, I'm creating this issue to make the "Dynamic query building" docs more clear.
The current issue is that for some reason the first time those docs are read, it's possible that people get the impression that using $dynamic()
on a query enables the possibility to make multiple calls to .where(...)
that are merged automatically by drizzle.
I know the docs don't state that drizzle merges the where calls and, if you read them after knowing the actual behavior, they are clear about the intent behind the $dynamic()
function, but they can be improved to make more clear that .where(...)
calls will keep the same behavior regarding overriding/merging.
Thanks!
I had opened a discussion in the ORM repo about adding a feature that transforms the query's result after it's been obtained from the driver, but I had forgotten that this is already possible using the then
method on the query builder, since it just extends Promise
.
I feel like the fact that the query builders extend Promise
is pretty easy to miss, and could be something worth noting in the documentation.
A frequently asked feature in the core API is some findFirst
and findFirstOrThrow
equivalent, and the documentation can provide an example as to how a developer than implement such functionality:
const user = db.select().from(users).limit(1).then((result) => result[0]);
In the following page Drizzle nextjs neon example, there is two example functions:
The first one shows how to add a todo:
import db from "@/db/drizzle";
import { todo } from "@/db/schema";
export const addTodo = async (id: number, text: string) => {
await db.insert(todo).values({
id: id,
text: text,
});
};
But at the end of the docs in the "Establish server-side functions", the function is missing the id param:
export const addTodo = async (text: string) => {
await db.insert(todo).values({
text: text,
});
revalidatePath("/");
};
I created a pull request to fix it: #277
In the Documentation's navigation sidebar there's a Benchmarks link without an href.
TypeScript complains when @types/better-sqlite3
is not installed. Update the guide so people using this library don't deal with the same issue. Example:
pnpm add drizzle-orm better-sqlite3
pnpm add -D drizzle-kit @types/better-sqlite3
Back in 0.24.0 I paid for a feature called iterator to be added to Drizzle. It's still in the code, but the documentation for it went away when the newer docs were added to Drizzle.
The feature helps when you need to pull back hundreds of thousands or millions of lines of code. It's a shame that the feature is still there but that there are no docs explaining how to use it. Bring back the docs!
I like how Stripe does it.
If i'm selecting SQLite in Docs, then show me SQLite docs for every other code-block.
Save it in local state or client-side cookie.
Doesn't make sense to keep showing me Postgres when I'm only looking for SQLite syntax.
This is what docs show (a folder named _meta
):
This is what I got (a folder named meta
):
Many, many links are not working in the docs. It seems to be the ones that are relative. Som examples:
Show the latest version the documentation is valid for.
I see a lot of docs entries say "Due to their official website...", but I believe this should be "According to their official website". Would you be open to a PR to change that?
Hello, there's a small typo, it should read We truly believe
, with a single l
😉
drizzle-orm-docs/pages/docs/overview.mdx
Line 25 in df4c1b8
https://www.loom.com/share/0266ac8288684f2a861941d015511459
It’s pretty confusing to navigate.
I understand that Drizzle ORM has supported the PostgreSQL array type since version 0.21.0, but I haven't been able to find any documentation on this feature.
After drizzle-team/drizzle-orm#1487 - these type casts are no longer necessary, and users should be guided to the new aggregation functions directly rather than explaining how the no-longer-necessary type casts work.
https://orm.drizzle.team/docs/select#aggregations
(yes, the function on aggregation helpers appears afterward, but this is only after the discussion on type casts from the sql count, etc functions. Ideally we could find a better example for type casting or .mapWith()
than one which should never be used anymore.)
Seems to happen on any page, e.g.: https://orm.drizzle.team/docs/overview
In Chrome, it eats 30% CPU. In Safari, it's about 16%. In Firefox it's fine.
While looking for any obvious causes, I noticed that if I resize the window so that the right sidebar disappears, the problem goes away. Maybe an issue with the ads? Although it seems to happen with and without uBlock Origin enabled.
I'm using a Macbook Pro M1 on Sonoma.
If you are interested in translate the documentation, I am able to do it
tinytext
, mediumtext
and longtext
can be imported using the drizzle-orm/mysql-core
but that are not documented in the MySQL column types.
From the transaction docs, it appears that no error will be thrown by calling rollback()
on a transaction, but doing so will throw a TransactionRollbackError
. Should the docs be updated?
Documented behavior:
The code provided in the docs:
const db = drizzle(...)
await db.transaction(async (tx) => {
const [account] = await tx.select({ balance: accounts.balance }).from(accounts).where(eq(users.name, 'Dan'));
if (account.balance < 100) {
await tx.rollback()
return
}
await tx.update(accounts).set({ balance: sql`${accounts.balance} - 100.00` }).where(eq(users.name, 'Dan'));
await tx.update(accounts).set({ balance: sql`${accounts.balance} + 100.00` }).where(eq(users.name, 'Andrew'));
});
seems to be misleading, as the await
before tx.rollback()
is a no-op, and the return
underneath will never be called. What will actually happen is that rollback()
will throw an error, which is uncaught in this code example.
Actual behavior:
const db = drizzle(...)
await db.transaction(async (tx) => {
const [account] = await tx.select({ balance: accounts.balance }).from(accounts).where(eq(users.name, 'Dan'));
if (account.balance < 100) {
// Throws a `TransactionRollbackError`
tx.rollback();
}
await tx.update(accounts).set({ balance: sql`${accounts.balance} - 100.00` }).where(eq(users.name, 'Dan'));
await tx.update(accounts).set({ balance: sql`${accounts.balance} + 100.00` }).where(eq(users.name, 'Andrew'));
});
This suggests that throwing was unintentional behavior, but according to this issue in the drizzle-orm
repo, it is intentional but undocumented.
We have it here: https://orm.drizzle.team/docs/column-types/pg#default-value
But not in a list of column types
The Drizzle ORM docs specify that LIKE
operator is "case sensitive" for SQLite
, MySQL
and PostgreSQL
databases at https://orm.drizzle.team/docs/operators#like
But actually the LIKE
operator is only case sensitive for PostgreSQL
[1] and is case insensitive for SQLite
[2] and MySQL
[3] databases.
I have tested SQLite
with bun-sqlite
driver and can confirm that the LIKE
filter returns case insensitive results for me.
File to be edited:
[1] https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
[2] https://www.sqlite.org/lang_expr.html
[3] https://dev.mysql.com/doc/refman/8.0/en/pattern-matching.html
Screenshots:
Drizzle favicon does not show on safari browsers. .svg
format is not supported.
Examples below of the behaviour, it can be a bit tough to find the tab again when all you see is 'D'
The petId is referenced incorrectly it should read petId: pet.id
not petId: pet.is
await db.select({
userId: users.id,
**petId: pets.is,**
}).from(user).leftJoin(pets, eq(users.id, pets.ownerId))
I'm so confused... why is there only negative tweets in this file and it seems to have been like that for months. I can't image this being unnoticed for that long so there must be a reason you guys have these tweets. Whatever it is, it was going to drive me away from using drizzle and switch to Prisma
https://orm.drizzle.team/docs/quick-sqlite/better-sqlite3
I think a link is supposed to be here, if someone can tell me the link, I can raise a PR
BetterSqlite3 documentation page has code from bun:sqlite docs page example
https://orm.drizzle.team/docs/quick-sqlite/better-sqlite3
import { drizzle, BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';
import { Database } from 'bun:sqlite';
I don't think there is a reason on why prisma should be displaying any default database type (currently postgres).
/installation-and-db-connection looks great and is good in terms of SEO, but it would be nice to have a dropdown or similar in /quick-start to change the database type in that section as well.
Hello Drizzle Team,
just like the title suggests, clarifying that you can use the Driverless Planetscale Driver without any adjustments on the drizzle connection would really be helpful since myself and other users where confused since it only shows mysql2 with a custom planetscale setting in the Docs.
That would be it :)
Keep up the great work!
Your project looks really wonderful guys! I found a Hickup in the docs on Joins:
**To achieve that, you can group the fields of a certain table in a nested object inside the `.fields()`:**
This is talking about the fields function but the corresponding code example does not feature that function
Hello! my proposal is due to the fact that many popular technologies like prisma, nest js and others have instructions on how to set up work with this or that technology for faster development. Can this be applied to drizzle? I think more people would use it if there was a clear guide to setting it up.
Thanks for reading, I'd love to hear your feedback.
Docs constantly provide examples like that
const result: User[] = await db.select().from(users);
even though correct usage would be
const result: User[] = await db.select().from(users).all();
Also it would be nice to know which other methods can you use - I assume .get
just gives you the first entry.
Hey team - when navigating to certain pages from google, it returns 404 pages.
https://www.loom.com/share/642134267e174dd0a9a0606f655f1090?sid=105d744e-ba6e-4176-83ca-fa6024556aee
I have to be honest, I had a bit of a chuckle seeing this - but surely this isn't intended, right?
(FYI, this is hardcoded here, I'm guessing this was meant to be temporary?)
On mobile, the navigation bar shows "Documentation" twice (one is for Drizzle ORM, and one is for Drizzle Kit).
No link for "read here"
More on sync and async APIs for sqlite - read here.
Lake a look at the last paragraph in this page/section: https://orm.drizzle.team/docs/get-started-sqlite#better-sqlite3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.