test(rfid): intial trials built

This commit is contained in:
2025-03-13 21:37:04 -05:00
parent 0054c8f7d4
commit da04e9d35d
15 changed files with 386 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
import {text, pgTable, numeric, index, timestamp, boolean, uuid, uniqueIndex, jsonb} from "drizzle-orm/pg-core";
import {createInsertSchema, createSelectSchema} from "drizzle-zod";
import {z} from "zod";
export const rfidReaders = pgTable(
"rfidReaders",
{
rfidReader_id: uuid("rfidReader_id").defaultRandom().primaryKey(),
reader: text("reader"),
readerIP: text("readerIP"),
lastHeartBeat: timestamp("lastHeartBeat").defaultNow(),
},
(table) => [
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
uniqueIndex("reader").on(table.reader),
]
);
// Schema for inserting a user - can be used to validate API requests
// export const insertRolesSchema = createInsertSchema(roles, {
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
// });
// Schema for selecting a Expenses - can be used to validate API responses
export const selectRolesSchema = createSelectSchema(rfidReaders);

View File

@@ -0,0 +1,28 @@
import {text, pgTable, numeric, index, timestamp, boolean, uuid, uniqueIndex, jsonb} from "drizzle-orm/pg-core";
import {createInsertSchema, createSelectSchema} from "drizzle-zod";
import {z} from "zod";
export const rfidTags = pgTable(
"rfidTags",
{
rfidTag_id: uuid("rfidTag_id").defaultRandom().primaryKey(),
tagHex: text("tagHex"),
tag: text("tag"),
lastRead: timestamp("timeStamp").defaultNow(),
counts: jsonb("counts").notNull(), //.default([{area: 1, timesHere: 5}]).notNull(),
lastareaIn: text("lastareaIn").notNull(),
runningNumber: numeric("runningNumber").notNull(),
created_at: timestamp("created_at").defaultNow(),
},
(table) => [
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
uniqueIndex("tagHex").on(table.tagHex),
]
);
// Schema for inserting a user - can be used to validate API requests
// export const insertRolesSchema = createInsertSchema(roles, {
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
// });
// Schema for selecting a Expenses - can be used to validate API responses
export const selectRolesSchema = createSelectSchema(rfidTags);