drizzle-orm 0.17.1-fd9b1de → 0.17.2-121a8a5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,8 +45,7 @@ npm install -D drizzle-kit
45
45
 
46
46
  ## Feature showcase (PostgreSQL)
47
47
 
48
- > **Note**
49
- > Don't forget to install `pg` and `@types/pg` packages for this example to work.
48
+ > **Note**: don't forget to install `pg` and `@types/pg` packages for this example to work.
50
49
 
51
50
  ```typescript
52
51
  import { eq } from 'drizzle-orm/expressions';
@@ -56,79 +55,82 @@ import { sql } from 'drizzle-orm/sql';
56
55
  import { Pool } from 'pg';
57
56
 
58
57
  export const users = pgTable('users', {
59
- id: serial('id').primaryKey(),
60
- fullName: text('full_name').notNull(),
61
- phone: varchar('phone', { length: 20 }).notNull(),
62
- role: text<'user' | 'admin'>('role').default('user').notNull(),
63
- cityId: integer('city_id').references(() => cities.id),
64
- createdAt: timestamp('created_at').defaultNow().notNull(),
65
- updatedAt: timestamp('updated_at').defaultNow().notNull(),
58
+ id: serial('id').primaryKey(),
59
+ fullName: text('full_name').notNull(),
60
+ phone: varchar('phone', { length: 20 }).notNull(),
61
+ role: text<'user' | 'admin'>('role').default('user').notNull(),
62
+ cityId: integer('city_id').references(() => cities.id),
63
+ createdAt: timestamp('created_at').defaultNow().notNull(),
64
+ updatedAt: timestamp('updated_at').defaultNow().notNull(),
66
65
  });
67
66
 
68
67
  export type User = InferModel<typeof users>;
69
68
  export type NewUser = InferModel<typeof users, 'insert'>;
70
69
 
71
70
  export const cities = pgTable('cities', {
72
- id: serial('id').primaryKey(),
73
- name: text('name').notNull(),
71
+ id: serial('id').primaryKey(),
72
+ name: text('name').notNull(),
74
73
  });
75
74
 
76
75
  export type City = InferModel<typeof cities>;
77
76
  export type NewCity = InferModel<typeof cities, 'insert'>;
78
77
 
79
78
  const pool = new Pool({
80
- connectionString: 'postgres://user:password@host:port/db',
79
+ connectionString: 'postgres://user:password@host:port/db',
81
80
  });
82
81
 
83
82
  const db = drizzle(pool);
84
83
 
85
84
  // Insert
86
85
  const newUser: NewUser = {
87
- fullName: 'John Doe',
88
- phone: '+123456789',
86
+ fullName: 'John Doe',
87
+ phone: '+123456789',
89
88
  };
90
89
  const insertedUsers /* : User */ = await db.insert(users).values(newUser).returning();
91
90
  const insertedUser = insertedUsers[0]!;
92
91
 
93
92
  const newCity: NewCity = {
94
- name: 'New York',
93
+ name: 'New York',
95
94
  };
96
95
  const insertedCities /* : City */ = await db.insert(cities).values(newCity).returning();
97
96
  const insertedCity = insertedCities[0]!;
98
97
 
99
98
  // Update
100
99
  const updateResult /* : { updated: Date }[] */ = await db.update(users)
101
- .set({ cityId: insertedCity.id, updatedAt: new Date() })
102
- .where(eq(users.id, insertedUser.id))
103
- .returning({ updated: users.updatedAt });
100
+ .set({ cityId: insertedCity.id, updatedAt: new Date() })
101
+ .where(eq(users.id, insertedUser.id))
102
+ .returning({ updated: users.updatedAt });
104
103
 
105
104
  // Select
106
105
  const allUsers /* : User[] */ = await db.select(users);
107
106
 
108
107
  // Select custom fields
109
108
  const upperCaseNames /* : { id: number; name: string }[] */ = await db.select(users)
110
- .fields({
111
- id: users.id,
112
- name: sql`upper(${users.fullName})`.as<string>(),
113
- });
109
+ .fields({
110
+ id: users.id,
111
+ name: sql`upper(${users.fullName})`.as<string>(),
112
+ });
114
113
 
115
114
  // Joins
116
115
  // You wouldn't BELIEVE how SMART the result type is! 😱
117
116
  const allUsersWithCities = await db.select(users)
118
- .fields({
119
- user: {
120
- id: users.id,
121
- name: users.fullName,
122
- },
123
- cityId: cities.id,
124
- cityName: cities.name,
125
- })
126
- .leftJoin(cities, eq(users.cityId, cities.id));
117
+ .fields({
118
+ user: {
119
+ id: users.id,
120
+ name: users.fullName,
121
+ },
122
+ cityId: cities.id,
123
+ cityName: cities.name,
124
+ })
125
+ .leftJoin(cities, eq(users.cityId, cities.id));
127
126
 
128
127
  // Delete
129
128
  const deletedNames /* : { name: string }[] */ = await db.delete(users)
130
- .where(eq(users.id, insertedUser.id))
131
- .returning({ name: users.fullName });
129
+ .where(eq(users.id, insertedUser.id))
130
+ .returning({ name: users.fullName });
132
131
  ```
133
132
 
134
- See [PostgreSQL docs](./drizzle-orm/src/pg-core/README.md) for full API reference.
133
+ **See full docs for further reference:**
134
+ - [PostgreSQL](./drizzle-orm/src/pg-core/README.md)
135
+ - [MySQL](./drizzle-orm/src/mysql-core/README.md)
136
+ - [SQLite](./drizzle-orm/src/sqlite-core/README.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.17.1-fd9b1de",
3
+ "version": "0.17.2-121a8a5",
4
4
  "description": "Drizzle ORM package for SQL databases",
5
5
  "scripts": {
6
6
  "build": "tsc && resolve-tspaths && cp ../README.md package.json dist/",
package/version.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,UAAU,EAAE,MAA2C,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,UAAU,EAAE,MAA0C,CAAC"}
package/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.npmVersion = exports.compatibilityVersion = void 0;
4
4
  exports.compatibilityVersion = 2;
5
- exports.npmVersion = require('../package.json').version;
5
+ exports.npmVersion = require('./package.json').version;
6
6
  //# sourceMappingURL=version.js.map
package/version.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,CAAC,CAAC;AACzB,QAAA,UAAU,GAAW,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,CAAC,CAAC;AACzB,QAAA,UAAU,GAAW,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC"}