feat: create and assign labels on trello import
This commit is contained in:
@@ -284,8 +284,7 @@ export const isSlugUnique = async (
|
||||
.eq("slug", args.slug)
|
||||
.eq("workspaceId", args.workspaceId)
|
||||
.is("deletedAt", null)
|
||||
.limit(1)
|
||||
.single();
|
||||
.limit(1);
|
||||
|
||||
return !data;
|
||||
return data?.length === 0;
|
||||
};
|
||||
|
||||
@@ -161,6 +161,18 @@ export const createCardLabelRelationship = async (
|
||||
return data;
|
||||
};
|
||||
|
||||
export const bulkCreateCardLabelRelationship = async (
|
||||
db: SupabaseClient<Database>,
|
||||
cardLabelRelationshipInput: { cardId: number; labelId: number }[],
|
||||
) => {
|
||||
const { data } = await db
|
||||
.from("_card_labels")
|
||||
.insert(cardLabelRelationshipInput)
|
||||
.select();
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getCardMemberRelationship = async (
|
||||
db: SupabaseClient<Database>,
|
||||
args: { cardId: number; memberId: number },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
@@ -35,6 +35,21 @@ export const create = async (
|
||||
return data;
|
||||
};
|
||||
|
||||
export const bulkCreate = async (
|
||||
db: SupabaseClient<Database>,
|
||||
labels: {
|
||||
publicId: string;
|
||||
name: string;
|
||||
colourCode: string;
|
||||
boardId: number;
|
||||
createdBy: string;
|
||||
}[],
|
||||
) => {
|
||||
const { data } = await db.from("label").insert(labels).select(`id`);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getAllByPublicIds = async (
|
||||
db: SupabaseClient<Database>,
|
||||
labelPublicIds: string[],
|
||||
|
||||
Reference in New Issue
Block a user