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

Serialization errors with FindResult, DeleteResult on dotnet #36

Closed
moonshxne opened this issue Sep 17, 2023 · 5 comments
Closed

Serialization errors with FindResult, DeleteResult on dotnet #36

moonshxne opened this issue Sep 17, 2023 · 5 comments

Comments

@moonshxne
Copy link
Contributor

Running the examples in samples/Commands fails because the MongoDB driver expects certain fields that don't exist in a FindResult<'T> or a UpdateResult to actually exist.

On my end, I can confirm that simply doing

[<BsonIgnoreExtraElements>]
type FindResult<'T> = { cursor: Cursor<'T>; ok: float }

resolves this (because Mongo also returns the operationTime field).

However, it's not just this one simple fix; the update command still fails because of the same issue. My conclusion is that we'll have to add this attribute to all of the types in Mondocks.Net's Types.fs; it follows that it might not make sense to share the types between Mondocks.Net and Mondocks.Fable?

Finally, a small feature request/design question: what determines which fields make it into the result structs? It would be nice, for instance, to also be able to also inspect the upserted items of an UpdateResult. See output reference here.

@AngelMunoz
Copy link
Owner

Hey there, I need some time to check this but thanks for the primer information.

I haven't had a chance to use mongo in a while, so I left this library to get some age... that's on me!

it follows that it might not make sense to share the types between Mondocks.Net and Mondocks.Fable?

It kind of makes sense if you ever share code but to be honest I guess on the fable side there are other mongo specific libraries that could be annotated to have a better DX I guess it is up to consideration if the fable target is really needed.

Finally, a small feature request/design question: what determines which fields make it into the result structs?

I don't particularly remember why... to be honest, I'm not married to anything so we can make changes in this area.

See output reference here.

Oh, nice I wasn't aware of this, this could help to fix up these kinds of issues.

On a side note, are you interested in making these changes? I'd gladly accept contributions as it might take me a while to get to work on this personally; we can push a new dotnet package rather than a fable one while I think about that one.

@moonshxne
Copy link
Contributor Author

Hey there, thanks for replying! I didn't create a PR because I wasn't super sure how you wanted to deal with code sharing. Can't do it today, but I'll add the types to Mondocks.Net with [] and go from there?

@AngelMunoz
Copy link
Owner

Yes, there's more utility in the dotnet version than the fable one, in any case we can revisit the fable package at some point if we need to but that's not a concern for now

@AngelMunoz
Copy link
Owner

I just merged the PR I'll try to put out a release later today in case you're blocked!

Thank you very much for this contribution!

@AngelMunoz
Copy link
Owner

https://www.nuget.org/packages/Mondocks.Net/0.6.0 published, we just need to wait for NuGet to index and list the package!

once again thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants