drizzle-orm-sqlite
Advanced tools
Comparing version 0.12.0-beta.18 to 0.12.0-beta.19
@@ -195,3 +195,2 @@ "use strict"; | ||
)`; | ||
session.run((0, drizzle_orm_1.sql) `CREATE SCHEMA IF NOT EXISTS "drizzle"`); | ||
session.run(migrationTableCreate); | ||
@@ -198,0 +197,0 @@ const dbMigrations = session.values((0, drizzle_orm_1.sql) `SELECT id, hash, created_at FROM "__drizzle_migrations" ORDER BY created_at DESC LIMIT 1`); |
{ | ||
"name": "drizzle-orm-sqlite", | ||
"version": "0.12.0-beta.18", | ||
"version": "0.12.0-beta.19", | ||
"description": "Drizzle ORM package for SQLite database", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,3 +27,3 @@ # Drizzle ORM | SQLite | ||
const users = db.select(users).execute(); | ||
const users = db.select(users).all(); | ||
``` | ||
@@ -40,3 +40,3 @@ | ||
const db: SQLiteDatabase = connector.connect(); | ||
const result = db.select(users).execute() | ||
const result = db.select(users).all() | ||
@@ -49,3 +49,3 @@ // bun js embedded sqlite connector | ||
const db: SQLiteBunDatabase = new SQLiteBunConnector(sqlite).connect(); | ||
const result = db.select(users).execute() | ||
const result = db.select(users).all() | ||
@@ -57,3 +57,3 @@ // Cloudflare D1 connector | ||
const db: SQLiteD1Database = new SQLiteD1Connector(env.DB).connect(); | ||
const result = await db.select(users).execute() // pay attention this one is async | ||
const result = await db.select(users).all() // pay attention this one is async | ||
``` | ||
@@ -123,6 +123,6 @@ | ||
const result: User[] = await db.select(users).execute() | ||
const result: User[] = await db.select(users).all() | ||
const insertUser = (user: InsertUser) => { | ||
return db.insert(users).values(user).execute() | ||
return db.insert(users).values(user).run() | ||
} | ||
@@ -204,9 +204,9 @@ ``` | ||
db.select(users).execute(); | ||
db.select(users).where(eq(users.id, 42)).execute(); | ||
db.select(users).all(); | ||
db.select(users).where(eq(users.id, 42)).get(); | ||
// you can combine filters with and(...) or or(...) | ||
db.select(users).where(and(eq(users.id, 42), eq(users.name, "Dan"))).execute(); | ||
db.select(users).where(and(eq(users.id, 42), eq(users.name, "Dan"))).all(); | ||
db.select(users).where(or(eq(users.id, 42), eq(users.id, 1))).execute(); | ||
db.select(users).where(or(eq(users.id, 42), eq(users.id, 1))).all(); | ||
@@ -217,11 +217,11 @@ // partial select | ||
field2: users.name, | ||
}).execute(); | ||
}).all(); | ||
const { field1, field2 } = result[0]; | ||
// limit offset & order by | ||
db.select(users).limit(10).offset(10).execute(); | ||
db.select(users).orderBy(asc(users.name)).execute(); | ||
db.select(users).orderBy(desc(users.name)).execute(); | ||
db.select(users).limit(10).offset(10).all(); | ||
db.select(users).orderBy(asc(users.name)).all(); | ||
db.select(users).orderBy(desc(users.name)).all(); | ||
// you can pass multiple order args | ||
db.select(users).orderBy(asc(users.name), desc(users.name)).execute(); | ||
db.select(users).orderBy(asc(users.name), desc(users.name)).all(); | ||
@@ -288,3 +288,3 @@ // list of all filter operators | ||
db.insert(users).values({ name: "Andrew", createdAt: +new Date() }).execute(); | ||
db.insert(users).values({ name: "Andrew", createdAt: +new Date() }).run(); | ||
@@ -298,6 +298,6 @@ // insert multiple users | ||
createdAt: +new Date(), | ||
}).execute(); | ||
}).run(); | ||
// insert with returning | ||
const insertedUser = db.insert(users).values({ name: "Dan", createdAt: +new Date() }).returning().execute() | ||
const insertedUser = db.insert(users).values({ name: "Dan", createdAt: +new Date() }).returning().get() | ||
``` | ||
@@ -310,7 +310,7 @@ | ||
.where(eq(usersTable.name, 'Dan')) | ||
.execute(); | ||
.run(); | ||
db.delete(users) | ||
.where(eq(usersTable.name, 'Dan')) | ||
.execute(); | ||
.run(); | ||
``` | ||
@@ -359,3 +359,3 @@ | ||
.orderBy(asc(orders.id)) | ||
.execute(); | ||
.all(); | ||
``` | ||
@@ -384,3 +384,3 @@ | ||
const result = db.select(cities).leftJoin(users, eq(cities2.id, users2.cityId)).execute() | ||
const result = db.select(cities).leftJoin(users, eq(cities2.id, users2.cityId)).all() | ||
``` | ||
@@ -413,3 +413,3 @@ | ||
.where(eq(chatGroups.id, 1)) | ||
.execute(); | ||
.all(); | ||
``` | ||
@@ -433,3 +433,3 @@ | ||
.where(eq(files.parent, "/")) | ||
.execute(); | ||
.all(); | ||
// will return files and folers and nested files for each folder at root dir | ||
@@ -446,3 +446,3 @@ ``` | ||
}).leftJoin(users, eq(users.cityId, cities.id)) | ||
.execute(); | ||
.all(); | ||
``` | ||
@@ -458,8 +458,8 @@ | ||
const q = db.select(customers).prepare(); | ||
q.execute() // SELECT * FROM customers | ||
q.all() // SELECT * FROM customers | ||
const q = db.select(customers).where(eq(customers.id, placeholder("id"))).prepare() | ||
q.execute({ id: 10 }) // SELECT * FROM customers WHERE id = 10 | ||
q.execute({ id: 12 }) // SELECT * FROM customers WHERE id = 12 | ||
q.get({ id: 10 }) // SELECT * FROM customers WHERE id = 10 | ||
q.get({ id: 12 }) // SELECT * FROM customers WHERE id = 12 | ||
@@ -470,3 +470,3 @@ const q = db.select(customers) | ||
q.execute({ name: "%an%" }) // SELECT * FROM customers WHERE name ilike '%an%' | ||
q.all({ name: "%an%" }) // SELECT * FROM customers WHERE name ilike '%an%' | ||
``` | ||
@@ -473,0 +473,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180665
2662