maybeNoT
maybeNoT
Explore posts from servers
PPrisma
Created by maybeNoT on 6/18/2024 in #help-and-questions
Pointing two relations to same field?
I have a scenario where it make sense to store informations about two 1-n relation in one field. I'm wondering if it is even possible to do something like this. Consider this example:
model User {
id Int @default(autoincrement()) @id
posts Post[] @relation(name: "rel")
}

model Post {
id Int @default(autoincrement()) @id
author1 User? @relation(name: "rel", fields: [author1Id], references: [id])
author1Id Int?
author2 User? @relation(name: "rel", fields: [author2Id], references: [id])
author2Id Int?
}
model User {
id Int @default(autoincrement()) @id
posts Post[] @relation(name: "rel")
}

model Post {
id Int @default(autoincrement()) @id
author1 User? @relation(name: "rel", fields: [author1Id], references: [id])
author1Id Int?
author2 User? @relation(name: "rel", fields: [author2Id], references: [id])
author2Id Int?
}
This shows me an error of course:
Error validating model "Post": Ambiguous relation detected. The fields `author1` and `author2` in model `Post` both refer to `User`. Please provide different relation names for them by adding `@relation(<name>).
Error validating model "Post": Ambiguous relation detected. The fields `author1` and `author2` in model `Post` both refer to `User`. Please provide different relation names for them by adding `@relation(<name>).
But ideally I would like to have relation about author1 and author2 stored separately on Post table, and informations about these posts related to authors in one field with Post[]. In other words, I want to store informations about Post related to the User in one array, doesn't matter if a User is in author1 or author2 field. Is something like this possible? - I'm using postgresql
1 replies
NNovu
Created by maybeNoT on 4/19/2024 in #💬│support
Self-Host: Triggering workflow to topic subscribers doesn't work
No description
25 replies
NNovu
Created by maybeNoT on 4/15/2024 in #💬│support
Triggering workflow to topic subscribers doesn't work.
I've got simple workflow defined send-mail which is just simply sending mails. I've tested it and I'm receiving mails when I'm triggering it to single subscriber, but it doesn't work when I try to trigger that to the topic. First I created the topic like so:
const createdTopic = await this.novu.topics.create({
key: 'some-key',
name: 'just name',
});
const createdTopic = await this.novu.topics.create({
key: 'some-key',
name: 'just name',
});
Then I added two subscribers like so:
const addedSubsToTopic = await this.novu.topics.addSubscribers('some-key', {
subscribers: ['6617e3701da082efc8ee2f92', '285u3298591y691'],
});
const addedSubsToTopic = await this.novu.topics.addSubscribers('some-key', {
subscribers: ['6617e3701da082efc8ee2f92', '285u3298591y691'],
});
And now I'm trying to trigger this worflow to the topic like this:
const { data } = await this.novu.trigger('send-mail', {
to: [{ type: TriggerRecipientsTypeEnum.TOPIC, topicKey: 'some-key' }],
payload: {},
});
const { data } = await this.novu.trigger('send-mail', {
to: [{ type: TriggerRecipientsTypeEnum.TOPIC, topicKey: 'some-key' }],
payload: {},
});
I'm getting back the transaction id in a response:
{
data: {
acknowledged: true,
status: 'processed',
transactionId: '5e99a3ba-5329-4e9e-8d37-cb77a7eb9b48'
}
}
{
data: {
acknowledged: true,
status: 'processed',
transactionId: '5e99a3ba-5329-4e9e-8d37-cb77a7eb9b48'
}
}
But no actual mail is delivered, and there's no such transaction id on my Activity Feed. I've got Novu self-hosted and deployed with docker. Any help appreaciated.
36 replies