Prisma Create multiple Records with same connection

i try to create multiple records in the model guild in ticket. It is a database which includes all active open tickets from a guild.

But if i want to create a second record because a second ticket was opend it only updates the already exist entry in ticket but i want to create a new one.

I dont know what in doing wrong at the moment, and looking for help please…

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>async function storeTicketData(guildId, ticketChannelID, ticketData) {
try {
await prisma.ticket.create({
data: {
guild: {
connect: { guildId: guildId.toString() }
},
ticketId: ticketData.ticketId || 0,
channel: BigInt(ticketChannelID),
owner: BigInt(ticketData.ticketOwner),
state: ticketData.state || 'open',
claimedBy: ticketData.claimedBy || null,
addedUsers: ticketData.addedUsers || [],
interactions: ticketData.interactions || [],
history: ticketData.history || [],
timer: ticketData.timer || false,
timerEnd: ticketData.timerEnd || null,
transcriptPermissions: ticketData.transcriptPermissions || ["private"],
transcriptUrl: ticketData.transcriptUrl || "",
panelId: ticketData.ticketPanelId,
}
});
} catch (error) {
if (error.code === 'P2002') {
console.error('Ticket with channel-id already exist in ticket database:', error);
} else {
console.error('Error on saving ticket to ticket database:', error);
}
}
}
</code>
<code>async function storeTicketData(guildId, ticketChannelID, ticketData) { try { await prisma.ticket.create({ data: { guild: { connect: { guildId: guildId.toString() } }, ticketId: ticketData.ticketId || 0, channel: BigInt(ticketChannelID), owner: BigInt(ticketData.ticketOwner), state: ticketData.state || 'open', claimedBy: ticketData.claimedBy || null, addedUsers: ticketData.addedUsers || [], interactions: ticketData.interactions || [], history: ticketData.history || [], timer: ticketData.timer || false, timerEnd: ticketData.timerEnd || null, transcriptPermissions: ticketData.transcriptPermissions || ["private"], transcriptUrl: ticketData.transcriptUrl || "", panelId: ticketData.ticketPanelId, } }); } catch (error) { if (error.code === 'P2002') { console.error('Ticket with channel-id already exist in ticket database:', error); } else { console.error('Error on saving ticket to ticket database:', error); } } } </code>
async function storeTicketData(guildId, ticketChannelID, ticketData) {
    try {
        
        await prisma.ticket.create({
            data: {
                guild: {
                    connect: { guildId: guildId.toString() } 
                },
                ticketId: ticketData.ticketId || 0,
                channel: BigInt(ticketChannelID),
                owner: BigInt(ticketData.ticketOwner),
                state: ticketData.state || 'open',
                claimedBy: ticketData.claimedBy || null,
                addedUsers: ticketData.addedUsers || [],
                interactions: ticketData.interactions || [],
                history: ticketData.history || [],
                timer: ticketData.timer || false,
                timerEnd: ticketData.timerEnd || null,
                transcriptPermissions: ticketData.transcriptPermissions || ["private"],
                transcriptUrl: ticketData.transcriptUrl || "",
                panelId: ticketData.ticketPanelId,
            }
        });

    } catch (error) {
        if (error.code === 'P2002') {
            console.error('Ticket with channel-id already exist in ticket database:', error);
        } else {
            console.error('Error on saving ticket to ticket database:', error);
        }
    }
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>model Guild {
id Int @id @default(autoincrement())
guildId String @unique
locale String @default("en-US")
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
TicketModule TicketModule[]
Tickets Ticket[]
StatisticsModule StatisticsModule[]
GuildMemberAdd GuildMemberAdd[]
GuildMemberLeave GuildMemberLeave[]
GuildMemberKick GuildMemberKick[]
GuildMemberBan GuildMemberBan[]
GuildStatistics GuildStatistics[]
@@schema("public")
}
</code>
<code>model Guild { id Int @id @default(autoincrement()) guildId String @unique locale String @default("en-US") createdAt DateTime @default(now()) updatedAt DateTime? @updatedAt TicketModule TicketModule[] Tickets Ticket[] StatisticsModule StatisticsModule[] GuildMemberAdd GuildMemberAdd[] GuildMemberLeave GuildMemberLeave[] GuildMemberKick GuildMemberKick[] GuildMemberBan GuildMemberBan[] GuildStatistics GuildStatistics[] @@schema("public") } </code>
model Guild {
    id               Int                @id @default(autoincrement())
    guildId          String             @unique
    locale           String             @default("en-US")
    createdAt        DateTime           @default(now())
    updatedAt        DateTime?          @updatedAt
    TicketModule     TicketModule[]
    Tickets          Ticket[]
    StatisticsModule StatisticsModule[]
    GuildMemberAdd   GuildMemberAdd[]
    GuildMemberLeave GuildMemberLeave[]
    GuildMemberKick  GuildMemberKick[]
    GuildMemberBan   GuildMemberBan[]
    GuildStatistics  GuildStatistics[]

    @@schema("public")
}

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>model Ticket {
id String @id @default(uuid())
ticketId BigInt
panelId String
guild Guild @relation(fields: [guildId], references: [id])
guildId Int
owner BigInt
channel BigInt @unique
state String @default("open")
claimedBy BigInt?
addedUsers Int[]
interactions Json[] // buttons modals etc
history Json[] // messages etc
timer Boolean
timerEnd DateTime?
transcriptPermissions String[] @default(["private"]) // public, private, role, user
transcriptUrl String? @default("")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@schema("tickets")
}
</code>
<code>model Ticket { id String @id @default(uuid()) ticketId BigInt panelId String guild Guild @relation(fields: [guildId], references: [id]) guildId Int owner BigInt channel BigInt @unique state String @default("open") claimedBy BigInt? addedUsers Int[] interactions Json[] // buttons modals etc history Json[] // messages etc timer Boolean timerEnd DateTime? transcriptPermissions String[] @default(["private"]) // public, private, role, user transcriptUrl String? @default("") createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@schema("tickets") } </code>
model Ticket {
    id       String @id @default(uuid())
    ticketId BigInt
    panelId  String
    guild    Guild  @relation(fields: [guildId], references: [id])
    guildId  Int
    owner    BigInt
    channel  BigInt @unique

    state        String @default("open")
    claimedBy    BigInt?
    addedUsers   Int[]
    interactions Json[] // buttons modals etc
    history      Json[] // messages etc

    timer    Boolean
    timerEnd DateTime?

    transcriptPermissions String[] @default(["private"]) // public, private, role, user
    transcriptUrl         String?  @default("")

    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt

    @@schema("tickets")
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật