[DOCS-14334] Is there a way to import a schema validation via cli? Created: 05/Apr/21  Updated: 30/Oct/23  Resolved: 05/Apr/21

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Minor - P4
Reporter: Albert Wong (Inactive) Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 2 years, 44 weeks, 2 days ago

 Description   

Description

I can't seem to find this answer on the docs website.  Can we get this fixed?

From Julia: Here is the doc I found, for reference: https://docs.mongodb.com/manual/core/schema-validation/

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Jeffrey Allen [ 05/Apr/21 ]

Correct. That is what is currently documented on the Schema Validation docs page.

To specify validation rules when creating a new collection, use db.createCollection() with the validator option.

To add document validation to an existing collection, use collMod command with the validator option.

Comment by Albert Wong (Inactive) [ 05/Apr/21 ]

You can use mongo shell and when creating or modifying a collection, you can append a validation. 

Comment by Jeffrey Allen [ 05/Apr/21 ]

Thanks for filing the feedback request. I'll close this ticket for now, but if we receive info that there is a way to do this we'll happily reopen. Cheers.

Comment by Albert Wong (Inactive) [ 05/Apr/21 ]

There is no CLI way to import a saved schema?   Hmm.   I'll create a feedback request then.  https://feedback.mongodb.com/forums/929233-mongodb-shell/suggestions/43075842-import-a-saved-schema-validation-from-a-json-file

Comment by Jeffrey Allen [ 05/Apr/21 ]

Hi albert.wong , do you mean to import a saved schema validation from a .json file? If so, I don't believe this is possible. The currently documented approach is the only method of specifying validation rules as far as I'm aware.

Comment by Albert Wong (Inactive) [ 05/Apr/21 ]

That doc is the one I mentioned that doesn't contain instructions on how to implement schema validation through the CLI. 

Generated at Thu Feb 08 08:10:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.