-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
35 lines (28 loc) · 850 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { drizzle } from "drizzle-orm/libsql/node";
import { eq } from "drizzle-orm";
import { usersTable } from "./db/schema.ts";
const db = drizzle({
connection: {
url: Deno.env.get("DB_URL")!,
authToken: Deno.env.get("DB_AUTH_TOKEN"),
},
});
async function main() {
const user: typeof usersTable.$inferInsert = {
name: "John",
age: 30,
email: "[email protected]",
};
await db.insert(usersTable).values(user);
console.log("New user created!");
const users = await db.select().from(usersTable);
console.log("Getting all users from the database:", users);
await db
.update(usersTable)
.set({ age: 31 })
.where(eq(usersTable.email, user.email));
console.log("User info updated!");
await db.delete(usersTable).where(eq(usersTable.email, user.email));
console.log("User deleted!");
}
main();