Giter VIP home page Giter VIP logo

drizzle-orm-docs's Introduction

πŸš€ Project Structure

MDX files are located in this folder

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ content/
β”‚   β”‚   └── documentation

🧞 Commands

All commands are run from the root of the project, from a terminal:

Command Action
pnpm install Installs dependencies
pnpm run dev Starts local dev server at localhost:4321
pnpm run build Build your production site to ./dist/
pnpm run preview Preview your build locally, before deploying
pnpm run astro ... Run CLI commands like astro add, astro check
pnpm run astro -- --help Get help using the Astro CLI

drizzle-orm-docs's People

Contributors

alexblokh avatar andriisherman avatar bent101 avatar crowne avatar czekoladowym avatar danieltprice avatar dankochetov avatar george1410 avatar hebilicious avatar jdeepd avatar jvliwanag avatar kyrylolvov avatar l-u-c-k-y avatar realmikesolo avatar romannabukhotnyi avatar tsg avatar vinay360 avatar vlad-stohnii avatar xeho91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

drizzle-orm-docs's Issues

Should "Due to" be "According to"

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?

docs (sql schema declaration) error with comment for MySQL tab

Image one: Screenshot 2024-01-13 at 11 58 51β€―AM



Image two: Screenshot 2024-01-13 at 11 51 46β€―AM

The "// declaring enum in database" comment should not be there for the MySql tab since an enum is not declared like it is for the PostgreSQL tab. As someone who isn't super familiar with sql this initially made me think that a table in sql is called an enum, which is wrong.

Save (PostgreSQL, MySQL , SQLite) preference

Hi
Whenever I switch between (PostgreSQL, MySQL, SQLite), the documentation site must save that into local storage, so when I navigate to a different page, I don't need to reselect it again. For example, if I'm using SQLite, I need to choose it again and again when I navigate to another page.
image

CRUD operation docs

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.

No favicons on Safari

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'

Screenshot 2023-06-09 at 14 03 55 Screenshot 2023-06-09 at 14 04 37

Iterator for MySQL

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!

Clarify that the β€˜dynamic’ mode for query builders does not merge `where` calls

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!

Partial select, incorrect reference to petId

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))

Wrong code example for Joins

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

Landing page show negative tweets

image

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

Clarify that the Planetscale Driverless Driver is compatible with Relational queries

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!

Docs still show outdated type casts on aggregation functions

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.)

Poor navigations on mobile

Nextra's sidebar, which contains the index of documents, is not shown in mobile view (width<768px) and readers cannot even open other pages.

I suggest using the native navbar provided by Nextra docs theme.

image

`TransactionRollbackError` behavior isn't documented

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.

Remember Local State of Database

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.

Show DB options before the first line of code

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.

Function missing id param in docs

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

Inform the user about the fact that query builders implement `Promise`

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]);

Clarify that pattern matching with `LIKE` operator is case insensitive for `SQLite` and `MySQL`

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:

Value is like other value, case sensitive

[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:

PostgresQL:
Screenshot from 2024-03-03 22-28-34

SQLite:
Screenshot from 2024-03-03 22-28-04

MySQL:
Screenshot from 2024-03-03 22-27-18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.