refactor(dbscheme): refactoring from opening and saving
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import {text, pgTable, timestamp, uuid, uniqueIndex, jsonb, integer} from "drizzle-orm/pg-core";
|
||||
import {createInsertSchema, createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {
|
||||
text,
|
||||
pgTable,
|
||||
timestamp,
|
||||
uuid,
|
||||
uniqueIndex,
|
||||
jsonb,
|
||||
integer,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const rfidTags = pgTable(
|
||||
"rfidTags",
|
||||
@@ -23,8 +31,8 @@ export const rfidTags = pgTable(
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
export const insertRolesSchema = createInsertSchema(rfidTags, {
|
||||
tagHex: z.string().min(3, {message: "Tag Should have more than 3 characters"}),
|
||||
});
|
||||
// export const insertRolesSchema = createInsertSchema(rfidTags, {
|
||||
// tagHex: z.string().min(3, {message: "Tag Should have more than 3 characters"}),
|
||||
// });
|
||||
// Schema for selecting a Expenses - can be used to validate API responses
|
||||
export const selectRolesSchema = createSelectSchema(rfidTags);
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import {text, pgTable, numeric, index, timestamp, boolean, uuid, uniqueIndex} from "drizzle-orm/pg-core";
|
||||
import {createInsertSchema, createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {users} from "./users.js";
|
||||
import {roles} from "./roles.js";
|
||||
import {modules} from "./modules.js";
|
||||
import {
|
||||
text,
|
||||
pgTable,
|
||||
numeric,
|
||||
index,
|
||||
timestamp,
|
||||
boolean,
|
||||
uuid,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
import { users } from "./users.js";
|
||||
import { roles } from "./roles.js";
|
||||
import { modules } from "./modules.js";
|
||||
|
||||
/*
|
||||
we will add the user
|
||||
@@ -33,13 +42,18 @@ export const userRoles = pgTable(
|
||||
},
|
||||
(table) => {
|
||||
// ensures only one user gets permissions to one role
|
||||
return [uniqueIndex("user_module_unique").on(table.user_id, table.module_id)];
|
||||
return [
|
||||
uniqueIndex("user_module_unique").on(
|
||||
table.user_id,
|
||||
table.module_id
|
||||
),
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
export const insertUserRolesSchema = createInsertSchema(userRoles, {
|
||||
role: z.string().min(3, {message: "Role must be at least 3 characters"}),
|
||||
});
|
||||
// export const insertUserRolesSchema = createInsertSchema(userRoles, {
|
||||
// role: z.string().min(3, {message: "Role must be at least 3 characters"}),
|
||||
// });
|
||||
// Schema for selecting a Expenses - can be used to validate API responses
|
||||
export const selectUserRolesSchema = createSelectSchema(userRoles);
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import {text, pgTable, numeric, index, timestamp, boolean, uuid, uniqueIndex} from "drizzle-orm/pg-core";
|
||||
import {createInsertSchema, createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {
|
||||
text,
|
||||
pgTable,
|
||||
numeric,
|
||||
index,
|
||||
timestamp,
|
||||
boolean,
|
||||
uuid,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const users = pgTable(
|
||||
"users",
|
||||
@@ -27,10 +36,10 @@ export const users = pgTable(
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
export const insertUsersSchema = createInsertSchema(users, {
|
||||
username: z.string().min(3, {message: "Username must be at least 3 characters"}),
|
||||
email: z.string().email({message: "Invalid email"}),
|
||||
password: z.string().min(8, {message: "Password must be at least 8 characters"}),
|
||||
});
|
||||
// export const insertUsersSchema = createInsertSchema(users, {
|
||||
// username: z.string().min(3, {message: "Username must be at least 3 characters"}),
|
||||
// email: z.string().email({message: "Invalid email"}),
|
||||
// password: z.string().min(8, {message: "Password must be at least 8 characters"}),
|
||||
// });
|
||||
// Schema for selecting a Expenses - can be used to validate API responses
|
||||
export const selectUsersSchema = createSelectSchema(users);
|
||||
|
||||
Reference in New Issue
Block a user