Skip to content

Commit

Permalink
Merge pull request #36 from kcoderhtml/dev
Browse files Browse the repository at this point in the history
bug: fix db no default value error
  • Loading branch information
taciturnaxolotl authored May 2, 2024
2 parents 3634c99 + e247979 commit ef4bfe5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion db/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { defineDb, defineTable, column } from "astro:db";

function generateRandomString() {
const chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let result = "";
for (let i = 0; i < 16; i++) {
const randomIndex = Math.floor(Math.random() * chars.length);
result += chars.charAt(randomIndex);
}
return result;
}

const Organization = defineTable({
columns: {
team: column.text({ primaryKey: true }),
Expand All @@ -15,7 +26,7 @@ const Organization = defineTable({
const User = defineTable({
columns: {
userId: column.text({ primaryKey: true }),
hash: column.text(),
hash: column.text({ default: generateRandomString() }),
team: column.text(),
name: column.text(),
email: column.text(),
Expand Down

0 comments on commit ef4bfe5

Please sign in to comment.