Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dal): add deleted index and type safety index #5309

Conversation

djabarovgeorge
Copy link
Contributor

What change does this PR introduce?

We want to optimize the call checking for non deleted subscribers.
This change is recommended by Mongodb Atlas.
As an alternative, the query may need to be changed.

Why was this change needed?

This will increase the query speed of calls looking for non deleted subscribers and will increase the trigger speed.

Other information (Screenshots)

Copy link

linear bot commented Mar 17, 2024

Comment on lines +185 to +186
function index(fields: IndexDefinition<SubscriberEntity>, options?: IndexOptions) {
subscriberSchema.index(fields, options);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rifont How about such an approach? while developing I noticed we don't have our indexes typed, meaning we can do indexed typos.
Doing this as a POC, I tried to make it a bit more generic but TS gave me problems :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mongoose is so poor when it comes to the types... yes the problems might be because we force some fields...
I like this approach 🙌

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it too, let's revisit generic typings as part of a holistic approach to strongly typing Mongoose. Ship it 🚀

Comment on lines +185 to +186
function index(fields: IndexDefinition<SubscriberEntity>, options?: IndexOptions) {
subscriberSchema.index(fields, options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mongoose is so poor when it comes to the types... yes the problems might be because we force some fields...
I like this approach 🙌

@LetItRock LetItRock merged commit d504201 into nv-3567-subscribers-are-duplicated-during-the-burst-of-events Mar 20, 2024
27 checks passed
@LetItRock LetItRock deleted the nv-3472-create-subscribers-deleted-index branch March 20, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants