forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dal): create topic subscribers schema and entity
- Loading branch information
1 parent
b3b5f70
commit 2e0fd5d
Showing
5 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './topic.entity'; | ||
export * from './topic-subscribers.entity'; |
13 changes: 13 additions & 0 deletions
13
libs/dal/src/repositories/topic/topic-subscribers.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Types } from 'mongoose'; | ||
|
||
import { EnvironmentId, OrganizationId, TopicId, UserId } from './topic.entity'; | ||
|
||
import { SubscriberId } from '../subscriber/subscriber.entity'; | ||
|
||
export class TopicSubscribersEntity { | ||
_environmentId: EnvironmentId; | ||
_organizationId: OrganizationId; | ||
_userId: UserId; | ||
topicId: TopicId; | ||
subscribers: [SubscriberId]; | ||
} |
35 changes: 35 additions & 0 deletions
35
libs/dal/src/repositories/topic/topic-subscribers.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as mongoose from 'mongoose'; | ||
import { Schema } from 'mongoose'; | ||
|
||
import { TopicSubscribersEntity } from './topic-subscribers.entity'; | ||
|
||
import { schemaOptions } from '../schema-default.options'; | ||
|
||
const topicSubscribersSchema = new Schema( | ||
{ | ||
_environmentId: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Environment', | ||
index: true, | ||
required: true, | ||
}, | ||
_organizationId: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Organization', | ||
index: true, | ||
required: true, | ||
}, | ||
_userId: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'User', | ||
index: true, | ||
required: true, | ||
}, | ||
subscribers: [{ type: Schema.Types.ObjectId, ref: 'Subscriber', required: true }], | ||
}, | ||
schemaOptions | ||
); | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export const TopicSubscribers = | ||
mongoose.models.Topic || mongoose.model<TopicSubscribersEntity>('TopicSubscribers', topicSubscribersSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters