Skip to content

Commit

Permalink
Add changelog, bump ORM version to 0.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dankochetov committed Feb 9, 2023
1 parent 0f4b037 commit c0cd0b3
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
17 changes: 17 additions & 0 deletions changelogs/drizzle-orm/0.19.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- Implemented selecting and joining a subquery. Example usage:

```ts
const sq = db
.select({
categoryId: courseCategoriesTable.id,
category: courseCategoriesTable.name,
total: sql`count(${courseCategoriesTable.id})`.as<number>(),
})
.from(courseCategoriesTable)
.groupBy(courseCategoriesTable.id, courseCategoriesTable.name)
.subquery('sq');
```

After that, just use the subquery instead of a table as usual.

- ❗ Replaced `db.select(table).fields({ ... })` syntax with `db.select({ ... }).from(table)` to look more like its SQL counterpart.
2 changes: 1 addition & 1 deletion drizzle-orm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drizzle-orm",
"version": "0.18.0",
"version": "0.19.0",
"description": "Drizzle ORM package for SQL databases",
"scripts": {
"build": "tsc && resolve-tspaths && cp ../README.md package.json dist/",
Expand Down
19 changes: 18 additions & 1 deletion drizzle-orm/src/mysql-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,24 @@ await db.select().from(users).orderBy(users.name);
await db.select().from(users).orderBy(desc(users.name));
// you can pass multiple order args
await db.select().from(users).orderBy(asc(users.name), desc(users.name));
```

#### Select from subquery

```typescript
const sq = db.select().from(users).where(eq(users.id, 42)).subquery('sq');
await db.select().from(sq);
```

Subqueries in joins are supported, too:

// list of all filter operators
```typescript
await db.select().from(users).leftJoin(sq, eq(users.id, sq.id));
```

#### List of all filter operators

```typescript
eq(column, value)
eq(column1, column2)
ne(column, value)
Expand Down Expand Up @@ -416,6 +432,7 @@ not(sqlExpression)

and(expressions: SQL[])
or(expressions: SQL[])

```

### Insert
Expand Down
18 changes: 17 additions & 1 deletion drizzle-orm/src/pg-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,24 @@ await db.select().from(users).orderBy(users.name);
await db.select().from(users).orderBy(desc(users.name));
// you can pass multiple order args
await db.select().from(users).orderBy(asc(users.name), desc(users.name));
```
#### Select from subquery
```typescript
const sq = db.select().from(users).where(eq(users.id, 42)).subquery('sq');
await db.select().from(sq);
```
Subqueries in joins are supported, too:
// list of all filter operators
```typescript
await db.select().from(users).leftJoin(sq, eq(users.id, sq.id));
```
#### List of all filter operators
```typescript
eq(column, value)
eq(column1, column2)
ne(column, value)
Expand Down
18 changes: 17 additions & 1 deletion drizzle-orm/src/sqlite-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,24 @@ db.select().from(users).orderBy(users.name).all();
db.select().from(users).orderBy(desc(users.name)).all();
// you can pass multiple order args
db.select().from(users).orderBy(asc(users.name), desc(users.name)).all();
```

#### Select from subquery

```typescript
const sq = db.select().from(users).where(eq(users.id, 42)).subquery('sq');
db.select().from(sq).all();
```

Subqueries in joins are supported, too:

// list of all filter operators
```typescript
db.select().from(users).leftJoin(sq, eq(users.id, sq.id)).all();
```

#### List of all filter operators

```typescript
eq(column, value)
eq(column1, column2)
ne(column, value)
Expand Down

0 comments on commit c0cd0b3

Please sign in to comment.