-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
36 lines (29 loc) · 959 Bytes
/
main.ts
File metadata and controls
36 lines (29 loc) · 959 Bytes
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
36
import { ZenStackClient } from "@zenstackhq/orm";
import { SqlJsDialect } from "@zenstackhq/orm/dialects/sql.js";
import initSqlJs from "sql.js";
import { PasswordHasherPlugin } from "./password-hasher-plugin";
import { schema } from "./zenstack/schema";
async function main() {
const SQL = await initSqlJs();
const db = new ZenStackClient(schema, {
dialect: new SqlJsDialect({ sqlJs: new SQL.Database() }),
plugins: [new PasswordHasherPlugin()],
});
// push database schema
await db.$pushSchema();
console.log("Creating user with plain text password...");
const user = await db.user.create({
data: {
email: "test@zenstack.dev",
password: "abc123",
},
});
console.log("User created:", user);
console.log("\nUpdating user password...");
const updatedUser = await db.user.update({
where: { id: user.id },
data: { password: "def456" },
});
console.log("Updated user:", updatedUser);
}
main();