Compare commits
2 Commits
c1a019a461
...
99f9531d32
| Author | SHA1 | Date | |
|---|---|---|---|
|
99f9531d32
|
|||
|
3c37fbf59b
|
@@ -3,20 +3,12 @@
|
|||||||
import { LocationContext } from "@/components/locationContext";
|
import { LocationContext } from "@/components/locationContext";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import Grouping from "./Grouping";
|
import Grouping from "./Grouping";
|
||||||
|
import { Group, JobCategory, updateGroups } from "./action";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
allJobs: JobCategory[];
|
allJobs: JobCategory[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JobCategory = {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Group = {
|
|
||||||
id: number;
|
|
||||||
jobs: number[];
|
|
||||||
};
|
|
||||||
export default function GroupCreator({ allJobs }: Props) {
|
export default function GroupCreator({ allJobs }: Props) {
|
||||||
const locationContext = useContext(LocationContext);
|
const locationContext = useContext(LocationContext);
|
||||||
const [usedJobs, setUsedJobs] = useState<number[]>([]);
|
const [usedJobs, setUsedJobs] = useState<number[]>([]);
|
||||||
@@ -40,7 +32,22 @@ export default function GroupCreator({ allJobs }: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit() {} //TODO! submit group
|
async function submit() {
|
||||||
|
if (
|
||||||
|
locationContext?.zone[0] == undefined ||
|
||||||
|
locationContext?.province[0] == undefined
|
||||||
|
) {
|
||||||
|
alert("ยังไม่ได้เลือกพื้นที่");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await updateGroups(
|
||||||
|
locationContext.province[0],
|
||||||
|
locationContext.zone[0],
|
||||||
|
groups,
|
||||||
|
);
|
||||||
|
|
||||||
|
alert("อัพเดทสำเร็จ");
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
locationContext?.zone[0] == undefined ||
|
locationContext?.zone[0] == undefined ||
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { JobCategory } from "./GroupCreator";
|
import { JobCategory } from "./action";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
availableJobs: JobCategory[];
|
availableJobs: JobCategory[];
|
||||||
@@ -19,16 +19,17 @@ export default function Grouping({
|
|||||||
const _id = parseInt(id);
|
const _id = parseInt(id);
|
||||||
const job = availableJobs.find((j) => j.id == _id);
|
const job = availableJobs.find((j) => j.id == _id);
|
||||||
if (job == undefined) return;
|
if (job == undefined) return;
|
||||||
setSelectedJob((old) => [...old, job]);
|
const newSelectedJob = [...selectedJob, job];
|
||||||
|
setSelectedJob(newSelectedJob);
|
||||||
selectJob(_id);
|
selectJob(_id);
|
||||||
|
updateGroup(newSelectedJob.map((j) => j.id));
|
||||||
}
|
}
|
||||||
function removeJobFromGroup(id: number) {
|
function removeJobFromGroup(id: number) {
|
||||||
setSelectedJob((old) => old.filter((j) => j.id != id));
|
const newSelectedJob = selectedJob.filter((j) => j.id != id);
|
||||||
|
setSelectedJob(newSelectedJob);
|
||||||
removeJob(id);
|
removeJob(id);
|
||||||
|
updateGroup(newSelectedJob.map((j) => j.id));
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
|
||||||
updateGroup(selectedJob.map((j) => j.id));
|
|
||||||
}, [selectedJob, updateGroup]);
|
|
||||||
return (
|
return (
|
||||||
<div className="m-2 flex w-full flex-col gap-2 rounded-md border border-black p-2 shadow-md">
|
<div className="m-2 flex w-full flex-col gap-2 rounded-md border border-black p-2 shadow-md">
|
||||||
{selectedJob.map((j) => (
|
{selectedJob.map((j) => (
|
||||||
|
|||||||
20
app/grouping/action.ts
Normal file
20
app/grouping/action.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
export type JobCategory = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Group = {
|
||||||
|
id: number;
|
||||||
|
jobs: number[];
|
||||||
|
};
|
||||||
|
|
||||||
|
//TODO: submit group
|
||||||
|
export async function updateGroups(
|
||||||
|
province: number,
|
||||||
|
zone: number,
|
||||||
|
groups: Group[],
|
||||||
|
) {
|
||||||
|
console.log({ province, zone, groups });
|
||||||
|
}
|
||||||
@@ -7,14 +7,15 @@ type Props = {
|
|||||||
export default function IdComponent({ updateIdList }: Props) {
|
export default function IdComponent({ updateIdList }: Props) {
|
||||||
const [idSet, setIdSet] = useState<Set<string>>(new Set());
|
const [idSet, setIdSet] = useState<Set<string>>(new Set());
|
||||||
const onValidId = (id: string) => {
|
const onValidId = (id: string) => {
|
||||||
setIdSet((prev) => new Set(prev.add(id)));
|
const newSet = new Set(idSet.add(id));
|
||||||
|
setIdSet(newSet);
|
||||||
|
updateIdList([...newSet]);
|
||||||
};
|
};
|
||||||
const removeCid = (id: string) => {
|
const removeCid = (id: string) => {
|
||||||
setIdSet((prev) => new Set([...prev].filter((x) => x !== id)));
|
const newSet = new Set([...idSet].filter((x) => x !== id));
|
||||||
|
setIdSet(newSet);
|
||||||
|
updateIdList([...newSet]);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
|
||||||
updateIdList([...idSet]);
|
|
||||||
}, [idSet, updateIdList]);
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center">
|
<div className="flex justify-center">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
|
|||||||
5
app/inside/action.ts
Normal file
5
app/inside/action.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
export async function saveUser(ids: string[]) {
|
||||||
|
console.log(ids);
|
||||||
|
} //TODO: submit inside user
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { saveUser } from "./action";
|
||||||
import IdComponent from "./IdComponent";
|
import IdComponent from "./IdComponent";
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const [idList, setIdList] = useState<string[]>([]);
|
const [idList, setIdList] = useState<string[]>([]);
|
||||||
function submit() {} //TODO! submit inside user
|
async function submit() {
|
||||||
|
await saveUser(idList);
|
||||||
|
alert("อัพเดทสำเร็จ");
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<IdComponent updateIdList={(cids) => setIdList(cids)} />
|
<IdComponent updateIdList={(cids) => setIdList(cids)} />
|
||||||
|
|||||||
1
drizzle/0003_overconfident_spencer_smythe.sql
Normal file
1
drizzle/0003_overconfident_spencer_smythe.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE users ADD `registerno` text;
|
||||||
499
drizzle/meta/0003_snapshot.json
Normal file
499
drizzle/meta/0003_snapshot.json
Normal file
@@ -0,0 +1,499 @@
|
|||||||
|
{
|
||||||
|
"version": "5",
|
||||||
|
"dialect": "sqlite",
|
||||||
|
"id": "e867b430-8022-40ca-9151-eab2690479e1",
|
||||||
|
"prevId": "cb28043a-c451-41dc-a5cc-14a1a74c756d",
|
||||||
|
"tables": {
|
||||||
|
"groups": {
|
||||||
|
"name": "groups",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"groups_name_unique": {
|
||||||
|
"name": "groups_name_unique",
|
||||||
|
"columns": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"isUnique": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"image_to_user": {
|
||||||
|
"name": "image_to_user",
|
||||||
|
"columns": {
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"image_name": {
|
||||||
|
"name": "image_name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"created_on": {
|
||||||
|
"name": "created_on",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"default": "CURRENT_TIMESTAMP"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"image_to_user_user_id_users_id_fk": {
|
||||||
|
"name": "image_to_user_user_id_users_id_fk",
|
||||||
|
"tableFrom": "image_to_user",
|
||||||
|
"tableTo": "users",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"opinions": {
|
||||||
|
"name": "opinions",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"name": "type",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false,
|
||||||
|
"default": "'5Choice'"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"opinions_name_unique": {
|
||||||
|
"name": "opinions_name_unique",
|
||||||
|
"columns": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"isUnique": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"provinces": {
|
||||||
|
"name": "provinces",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"provinces_name_unique": {
|
||||||
|
"name": "provinces_name_unique",
|
||||||
|
"columns": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"isUnique": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"users": {
|
||||||
|
"name": "users",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"firstName": {
|
||||||
|
"name": "firstName",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"lastName": {
|
||||||
|
"name": "lastName",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"registerno": {
|
||||||
|
"name": "registerno",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"name": "title",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"cid": {
|
||||||
|
"name": "cid",
|
||||||
|
"type": "text(13)",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"age": {
|
||||||
|
"name": "age",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"name": "phone",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"public_phone": {
|
||||||
|
"name": "public_phone",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"facebook": {
|
||||||
|
"name": "facebook",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"twitter": {
|
||||||
|
"name": "twitter",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"tiktok": {
|
||||||
|
"name": "tiktok",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"other_social": {
|
||||||
|
"name": "other_social",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"name": "image",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"name": "email",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"job": {
|
||||||
|
"name": "job",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"education": {
|
||||||
|
"name": "education",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"vision": {
|
||||||
|
"name": "vision",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
"name": "reason",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"group_id": {
|
||||||
|
"name": "group_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"zone_id": {
|
||||||
|
"name": "zone_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"verified": {
|
||||||
|
"name": "verified",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false,
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"users_cid_unique": {
|
||||||
|
"name": "users_cid_unique",
|
||||||
|
"columns": [
|
||||||
|
"cid"
|
||||||
|
],
|
||||||
|
"isUnique": true
|
||||||
|
},
|
||||||
|
"users_phone_unique": {
|
||||||
|
"name": "users_phone_unique",
|
||||||
|
"columns": [
|
||||||
|
"phone"
|
||||||
|
],
|
||||||
|
"isUnique": true
|
||||||
|
},
|
||||||
|
"phone_idx": {
|
||||||
|
"name": "phone_idx",
|
||||||
|
"columns": [
|
||||||
|
"phone"
|
||||||
|
],
|
||||||
|
"isUnique": false
|
||||||
|
},
|
||||||
|
"image_idx": {
|
||||||
|
"name": "image_idx",
|
||||||
|
"columns": [
|
||||||
|
"image"
|
||||||
|
],
|
||||||
|
"isUnique": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"users_group_id_groups_id_fk": {
|
||||||
|
"name": "users_group_id_groups_id_fk",
|
||||||
|
"tableFrom": "users",
|
||||||
|
"tableTo": "groups",
|
||||||
|
"columnsFrom": [
|
||||||
|
"group_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"users_zone_id_zones_id_fk": {
|
||||||
|
"name": "users_zone_id_zones_id_fk",
|
||||||
|
"tableFrom": "users",
|
||||||
|
"tableTo": "zones",
|
||||||
|
"columnsFrom": [
|
||||||
|
"zone_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"user_opinions": {
|
||||||
|
"name": "user_opinions",
|
||||||
|
"columns": {
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"opinion_id": {
|
||||||
|
"name": "opinion_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"choice": {
|
||||||
|
"name": "choice",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"default": "'ignore'"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"user_opinions_user_id_users_id_fk": {
|
||||||
|
"name": "user_opinions_user_id_users_id_fk",
|
||||||
|
"tableFrom": "user_opinions",
|
||||||
|
"tableTo": "users",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"user_opinions_opinion_id_opinions_id_fk": {
|
||||||
|
"name": "user_opinions_opinion_id_opinions_id_fk",
|
||||||
|
"tableFrom": "user_opinions",
|
||||||
|
"tableTo": "opinions",
|
||||||
|
"columnsFrom": [
|
||||||
|
"opinion_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {
|
||||||
|
"user_opinions_user_id_opinion_id_pk": {
|
||||||
|
"columns": [
|
||||||
|
"opinion_id",
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"name": "user_opinions_user_id_opinion_id_pk"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"zones": {
|
||||||
|
"name": "zones",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
},
|
||||||
|
"province_id": {
|
||||||
|
"name": "province_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"autoincrement": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"zones_name_province_id_unique": {
|
||||||
|
"name": "zones_name_province_id_unique",
|
||||||
|
"columns": [
|
||||||
|
"name",
|
||||||
|
"province_id"
|
||||||
|
],
|
||||||
|
"isUnique": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"zones_province_id_provinces_id_fk": {
|
||||||
|
"name": "zones_province_id_provinces_id_fk",
|
||||||
|
"tableFrom": "zones",
|
||||||
|
"tableTo": "provinces",
|
||||||
|
"columnsFrom": [
|
||||||
|
"province_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enums": {},
|
||||||
|
"_meta": {
|
||||||
|
"schemas": {},
|
||||||
|
"tables": {},
|
||||||
|
"columns": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,13 @@
|
|||||||
"when": 1715319087385,
|
"when": 1715319087385,
|
||||||
"tag": "0002_gigantic_sentry",
|
"tag": "0002_gigantic_sentry",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 3,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1715935487997,
|
||||||
|
"tag": "0003_overconfident_spencer_smythe",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ export const user = sqliteTable(
|
|||||||
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
||||||
firstName: text("firstName").notNull(),
|
firstName: text("firstName").notNull(),
|
||||||
lastName: text("lastName").notNull(),
|
lastName: text("lastName").notNull(),
|
||||||
|
registerno: text("registerno"),
|
||||||
title: text("title").notNull(),
|
title: text("title").notNull(),
|
||||||
cid: text("cid", { length: 13 }).notNull().unique(),
|
cid: text("cid", { length: 13 }).notNull().unique(),
|
||||||
age: integer("age").notNull(),
|
age: integer("age").notNull(),
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const opinionUpdateSchema = createInsertSchema(userOpinion)
|
|||||||
verified: true,
|
verified: true,
|
||||||
})
|
})
|
||||||
.required({ opinionId: true });
|
.required({ opinionId: true });
|
||||||
|
|
||||||
type OpinionInsertSchema = z.infer<typeof opinionInsertSchema>;
|
type OpinionInsertSchema = z.infer<typeof opinionInsertSchema>;
|
||||||
type UserInsertSchema = z.infer<typeof userInsertSchema>;
|
type UserInsertSchema = z.infer<typeof userInsertSchema>;
|
||||||
type UserUpdateSchema = z.infer<typeof userUpdateSchema>;
|
type UserUpdateSchema = z.infer<typeof userUpdateSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user