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

Modify a Validator #1057

Closed
GreeFine opened this issue Mar 27, 2024 · 2 comments
Closed

Modify a Validator #1057

GreeFine opened this issue Mar 27, 2024 · 2 comments
Assignees

Comments

@GreeFine
Copy link

GreeFine commented Mar 27, 2024

To have a validator set in a collection, I use the validator field in the CreateCollectionOptions.

But I need to be able to change the validation schema of an existing collection, and I found no way of doing it. (without dropping and recreating the Collection)

Is there a function/option I didn't find, or is the feature missing ?
If missing, could I propose the feature in a PR, and expect it's to be merged at some time ?

@abr-egn
Copy link
Contributor

abr-egn commented Apr 1, 2024

You're right that the Rust driver doesn't expose a helper method for that; as far as I can tell, drivers for other languages don't either. It's not part of the MongoDB driver specification, as we generally think of it as an administrative action rather than a client application operation.

That said, you're not the first to ask for this, so I'm going to re-open internal discussion on this :) While I appreciate the offer of a PR, I don't think we'd be able to accept one for new user-facing API surface. In the meanwhile, you can use the run_command method to directly run the collMod operation (example).

@abr-egn abr-egn removed the triage label Apr 1, 2024
@GreeFine
Copy link
Author

GreeFine commented Apr 3, 2024

Thanks for the example that might work.

I am very surprised by the fact that this isn't something that you already had on the other drivers, makes sense that a new user-facing API needs to be done by your team.

Is there a link to the internal discussion or any resources on this issue ? I am curious as to why it is the case, and also looking for how we should best use the validators.
In our project, we use them to prevent, detect mismatch data exchanged between two crates through the Mongo database, but the data format, schema and thus validator are evolving rapidly, and we want to automatically have the newest validators in place. (a bit like embedded migration for PostgreSQL)

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