refactor: add organizations system

This commit is contained in:
Mauricio Siu
2025-02-09 20:53:06 -06:00
parent fafc238e70
commit 8bd72a8a34
47 changed files with 359 additions and 171 deletions

View File

@@ -94,8 +94,8 @@ export const updateAdminById = async (
};
export const isAdminPresent = async () => {
const admin = await db.query.users.findFirst({
where: eq(users.role, "admin"),
const admin = await db.query.user.findFirst({
where: eq(user.role, "admin"),
});
if (!admin) {
return false;

View File

@@ -100,10 +100,11 @@ export const findAuthByEmail = async (email: string) => {
};
export const findAuthById = async (authId: string) => {
const result = await db.query.auth.findFirst({
where: eq(auth.id, authId),
const result = await db.query.user.findFirst({
where: eq(user.id, authId),
columns: {
password: false,
createdAt: false,
updatedAt: false,
},
});
if (!result) {

View File

@@ -20,18 +20,16 @@ export const findUserById = async (userId: string) => {
export const findUserByAuthId = async (authId: string) => {
const userR = await db.query.user.findFirst({
where: eq(user.authId, authId),
with: {
auth: true,
},
where: eq(user.id, authId),
with: {},
});
if (!user) {
if (!userR) {
throw new TRPCError({
code: "NOT_FOUND",
message: "User not found",
});
}
return user;
return userR;
};
export const findUsers = async (adminId: string) => {