refactor: reinstate drizzle
This commit is contained in:
@@ -57,18 +57,11 @@ export const cardRouter = createTRPCRouter({
|
||||
|
||||
let index = 0;
|
||||
|
||||
if (list.cards.length) {
|
||||
if (input.position === "end" && lastCard) index = lastCard.index + 1;
|
||||
|
||||
if (input.position === "start") {
|
||||
await cardRepo.pushIndex(ctx.db, {
|
||||
listId: list.id,
|
||||
cardIndex: 0,
|
||||
});
|
||||
}
|
||||
if (list.cards.length && input.position === "end" && lastCard) {
|
||||
index = lastCard.index + 1;
|
||||
}
|
||||
|
||||
const newCard = await cardRepo.create(ctx.db, {
|
||||
const newCard = await cardRepo.create(ctx.drizzleDb, {
|
||||
title: input.title,
|
||||
description: input.description,
|
||||
createdBy: userId,
|
||||
@@ -76,7 +69,7 @@ export const cardRouter = createTRPCRouter({
|
||||
index,
|
||||
});
|
||||
|
||||
const newCardId = newCard?.id;
|
||||
const newCardId = newCard.id;
|
||||
|
||||
if (!newCardId)
|
||||
throw new TRPCError({
|
||||
@@ -84,12 +77,6 @@ export const cardRouter = createTRPCRouter({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
});
|
||||
|
||||
await cardActivityRepo.create(ctx.db, {
|
||||
type: "card.created",
|
||||
cardId: newCard.id,
|
||||
createdBy: userId,
|
||||
});
|
||||
|
||||
if (newCardId && input.labelPublicIds.length) {
|
||||
const labels = await labelRepo.getAllByPublicIds(
|
||||
ctx.db,
|
||||
|
||||
@@ -24,7 +24,7 @@ export const feedbackRouter = createTRPCRouter({
|
||||
code: "UNAUTHORIZED",
|
||||
});
|
||||
|
||||
const result = await feedbackRepo.create(ctx.adminDb, {
|
||||
const result = await feedbackRepo.create(ctx.db, {
|
||||
feedback: input.feedback,
|
||||
createdBy: userId,
|
||||
url: input.url,
|
||||
|
||||
@@ -73,12 +73,12 @@ export const memberRouter = createTRPCRouter({
|
||||
let hashedToken: string | undefined;
|
||||
let verificationType: string | undefined;
|
||||
|
||||
const existingUser = await userRepo.getByEmail(ctx.adminDb, input.email);
|
||||
const existingUser = await userRepo.getByEmail(ctx.db, input.email);
|
||||
|
||||
if (existingUser) {
|
||||
invitedUserId = existingUser.id;
|
||||
|
||||
const magicLink = await ctx.adminDb.auth.admin.generateLink({
|
||||
const magicLink = await ctx.db.auth.admin.generateLink({
|
||||
type: "magiclink",
|
||||
email: input.email,
|
||||
options: {
|
||||
@@ -89,7 +89,7 @@ export const memberRouter = createTRPCRouter({
|
||||
hashedToken = magicLink.data.properties?.hashed_token;
|
||||
verificationType = magicLink.data.properties?.verification_type;
|
||||
} else {
|
||||
const invite = await ctx.adminDb.auth.admin.generateLink({
|
||||
const invite = await ctx.db.auth.admin.generateLink({
|
||||
type: "invite",
|
||||
email: input.email,
|
||||
options: {
|
||||
@@ -111,7 +111,7 @@ export const memberRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
|
||||
const newUser = await userRepo.create(ctx.adminDb, {
|
||||
const newUser = await userRepo.create(ctx.db, {
|
||||
email: invitedUserEmail,
|
||||
id: invitedUserAuthId,
|
||||
stripeCustomerId: stripeCustomer.id,
|
||||
|
||||
@@ -37,7 +37,7 @@ export const userRouter = createTRPCRouter({
|
||||
code: "UNAUTHORIZED",
|
||||
});
|
||||
|
||||
const result = await userRepo.getById(ctx.db, userId);
|
||||
const result = await userRepo.getById(ctx.drizzleDb, userId);
|
||||
|
||||
if (!result?.name) {
|
||||
throw new TRPCError({
|
||||
@@ -81,7 +81,7 @@ export const userRouter = createTRPCRouter({
|
||||
code: "UNAUTHORIZED",
|
||||
});
|
||||
|
||||
const result = await userRepo.update(ctx.adminDb, userId, input);
|
||||
const result = await userRepo.update(ctx.db, userId, input);
|
||||
|
||||
if (!result) {
|
||||
throw new TRPCError({
|
||||
|
||||
@@ -126,7 +126,7 @@ export const workspaceRouter = createTRPCRouter({
|
||||
|
||||
const workspacePublicId = generateUID();
|
||||
|
||||
const result = await workspaceRepo.create(ctx.adminDb, {
|
||||
const result = await workspaceRepo.create(ctx.db, {
|
||||
publicId: workspacePublicId,
|
||||
name: input.name,
|
||||
slug: workspacePublicId,
|
||||
@@ -174,7 +174,7 @@ export const workspaceRouter = createTRPCRouter({
|
||||
);
|
||||
|
||||
const reservedOrPremiumWorkspaceSlug =
|
||||
await workspaceSlugRepo.getWorkspaceSlug(ctx.adminDb, input.slug);
|
||||
await workspaceSlugRepo.getWorkspaceSlug(ctx.db, input.slug);
|
||||
|
||||
const isWorkspaceSlugAvailable =
|
||||
await workspaceRepo.isWorkspaceSlugAvailable(ctx.db, input.slug);
|
||||
@@ -261,7 +261,7 @@ export const workspaceRouter = createTRPCRouter({
|
||||
const slug = input.workspaceSlug.toLowerCase();
|
||||
// check slug is not reserved
|
||||
const workspaceSlug = await workspaceSlugRepo.getWorkspaceSlug(
|
||||
ctx.adminDb,
|
||||
ctx.db,
|
||||
slug,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user