-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
900a908
commit 832b9b3
Showing
1 changed file
with
18 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
'use server'; | ||
import { db, schema } from '@/db'; | ||
import { faker } from '@faker-js/faker'; | ||
import * as argon2 from 'argon2'; | ||
import { InferInsertModel } from 'drizzle-orm'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export default async function page() { | ||
const pass = faker.internet.password(); | ||
const passwordHash = await argon2.hash(pass); | ||
const result = await db | ||
.insert(schema.user) | ||
.values([ | ||
{ | ||
id: Math.random() * 1000, | ||
username: faker.internet.userName(), | ||
eamil: faker.internet.email(), | ||
passwordHash, | ||
}, | ||
]); | ||
console.log(result[0].insertId); | ||
return <h1>Hello from user page</h1>; | ||
const user = { | ||
email: faker.internet.email(), | ||
username: faker.internet.userName(), | ||
passwordHash, | ||
} satisfies InferInsertModel<typeof schema.user>; | ||
const result = await db.insert(schema.user).values(user); | ||
|
||
return ( | ||
<> | ||
<h1> | ||
A user with the name of {user.username} was inserted with an id of{' '} | ||
{result[0].insertId} | ||
</h1> | ||
</> | ||
); | ||
} |