コンテンツにスキップ

検索はプロダクションビルドでのみ利用可能です。 ローカルでテストするには、サイトをビルドしてプレビューしてください。

Cellar リレーション

Cellar DB のリレーション定義です。Drizzle ORM v1.0 beta の Relations V2 (defineRelations) を使用しています。



親テーブル子テーブルリレーション名FK
shopcontactcontactscontact.shopId → shop.id
shopchat_roomchatRoomschat_room.shopId → shop.id
shopbroadcastbroadcastsbroadcast.shopId → shop.id
shoplabellabelslabel.shopId → shop.id
shopshop_line_accountlineAccountsshop_line_account.shopId → shop.id
shopshop_transfertransfersshop_transfer.shopId → shop.id
shopshop_pureloversshopPureloversshop_purelovers.shopId → shop.id
shopshop_push_subscriptionpushSubscriptionsshop_push_subscription.shopId → shop.id
shopshop_email_recipientemailRecipientsshop_email_recipient.shopId → shop.id
shopdomain_blacklistdomainBlacklistsdomain_blacklist.shopId → shop.id
contactchat_roomchatRoomschat_room.contactId → contact.id
contactcontact_pureloverscontactPureloverscontact_purelovers.userId → contact.userId
contactcontact_chat_ngchatNgStatusescontact_chat_ng.contactId → contact.id
contactcontact_chat_ng_historychatNgHistoriescontact_chat_ng_history.contactId → contact.id
chat_roomchat_messagemessageschat_message.roomId → chat_room.id
chat_roomuser_room_stateuserRoomStatesuser_room_state.roomId → chat_room.id
chat_messagechat_attachmentattachmentschat_attachment.messageId → chat_message.id
親テーブル子テーブルリレーション名FK
shopshop_notification_settingnotificationSettingshop_notification_setting.shopId → shop.id
子テーブル親テーブルリレーション名FK
contactshopshopcontact.shopId → shop.id
chat_roomshopshopchat_room.shopId → shop.id
chat_roomcontactcontactchat_room.contactId → contact.id
chat_messagechat_roomroomchat_message.roomId → chat_room.id
chat_attachmentchat_messagemessagechat_attachment.messageId → chat_message.id
user_room_statechat_roomroomuser_room_state.roomId → chat_room.id
broadcastshopshopbroadcast.shopId → shop.id
labelshopshoplabel.shopId → shop.id
shop_line_accountshopshopshop_line_account.shopId → shop.id
shop_transfershopshop / toOrganizationshop_transfer.shopId / toOrganizationId → shop.id
shop_pureloversshopshopshop_purelovers.shopId → shop.id
contact_pureloverscontactcontactscontact_purelovers.userId → contact.userId
contact_chat_ngcontactcontactcontact_chat_ng.contactId → contact.id
contact_chat_ng_historycontactcontactcontact_chat_ng_history.contactId → contact.id
shop_notification_settingshopshopshop_notification_setting.shopId → shop.id
shop_push_subscriptionshopshopshop_push_subscription.shopId → shop.id
shop_email_recipientshopshopshop_email_recipient.shopId → shop.id
domain_blacklistshopshopdomain_blacklist.shopId → shop.id

リレーション定義は packages/cellar/src/relations.tsdefineRelations を使用して宣言されています。

import { defineRelations } from 'drizzle-orm';
import * as schema from './schema';
export const relations = defineRelations(schema, (r) => ({
shop: {
contacts: r.many.contact(),
chatRooms: r.many.chatRoom(),
broadcasts: r.many.broadcast()
// ...
},
contact: {
shop: r.one.shop({
from: r.contact.shopId,
to: r.shop.id
})
// ...
}
// ...
}));