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

Log when a mongo-specific action is being skipped #810

Closed
samcoenen opened this issue Apr 4, 2023 · 1 comment
Closed

Log when a mongo-specific action is being skipped #810

samcoenen opened this issue Apr 4, 2023 · 1 comment
Labels
enhancement Improve an existing Feature not a typegoose issue This is not a typegoose issue / This pr addresses something that shouldnt be in typegoose

Comments

@samcoenen
Copy link

Describe what you need | want

I was trying to execute the following update statement:

await this.statisticModel
  .updateOne(
    { ... },
    { $inc: { "value.history.2023.03.n": 1 } }
  )
  .lean()
  .exec();

but it wouldn't give me any results. When I enabled logging, the query wasn't even being logged so nothing was executing.

I wasted 2 hours before I realized that this is "intended" behavior because the default strict option for a model is true and since Typegoose doesn't recognise $inc as an existing property on my model, it is skipping this query entirely. Passing { strict: false } to this update fixed the "issue".

It think it only makes sense that if a mongo-specific action (such as $inc) is not being executed because of the strict option, it should trigger a log message (if logging is enabled) so that the developer knows what is happening, because this is probably not the intended behaviour.

Do you have already an idea for the implementation?

Sure, have a "whitelist" of actions that are checked when skipping properties and log it when there's a match.
But I do not have the time, nor do I know the codebase of Typegoose so I'm not volunteering to implement this myself. 🙂

@samcoenen samcoenen added the feature Adds a new Feature or Request label Apr 4, 2023
@hasezoey hasezoey added enhancement Improve an existing Feature typegoose: working as intended Its a typegoose functionality, which is working as intended not a typegoose issue This is not a typegoose issue / This pr addresses something that shouldnt be in typegoose and removed feature Adds a new Feature or Request typegoose: working as intended Its a typegoose functionality, which is working as intended labels Apr 4, 2023
@hasezoey
Copy link
Member

hasezoey commented Apr 4, 2023

i think you ran into a issue with strictQuery rather than strict itself, also this is not part of typegoose and is purely mongoose, please open a issue there (but know that strictQuery is false again for mongoose 7 Automattic/mongoose#12842)

@hasezoey hasezoey closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve an existing Feature not a typegoose issue This is not a typegoose issue / This pr addresses something that shouldnt be in typegoose
Projects
None yet
Development

No branches or pull requests

2 participants