[SERVER-3536] templates for schemas Created: 04/Aug/11 Updated: 06/Dec/22 Resolved: 06/Mar/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Jason Voorhees | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Done | Votes: | 9 |
| Labels: | insert, query, schema, update | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
The user is said to gain more "flexibility" in a schema-less database. However the option to gain schema-based advantages are NOT available. Proposal:
This would provide guaranteed queries (skip those pesky membership tests) and assist developers in planning and maintaining a mongodb instance by simplifying and solidifying common and/or boilerplate data operations. |
| Comments |
| Comment by Asya Kamsky [ 06/Mar/18 ] |
|
3.6 added support for JSON Schema both as query operator and schema validation syntax. This seems to address many of the asks in this ticket - ability to only allow documents that match the schema, or optionally accepting ones that don't with a warning logged, plus ability to query for documents that match a particular schema. I'm going to close this ticket - components of original request that aren't addressed by JSON Schema (providing default values for fields not set) should be tracked by separate smaller/more narrowly defined tickets (some already exist list SERVER-24430 for setting default). |
| Comment by Marcel Bennett [ 26/Jan/15 ] |
|
As noted in I'm not as concerned with these being part of this issue and would prefer the other issue re-opened, but this is needed simply to store JSON Schemas in Mongo at all, like for a Node application for managing Schema records. |
| Comment by Marcel Bennett [ 24/Jan/15 ] |
|
I would rather see JSON Schema used with one non-standard element than something completely incompatible. My workplace is investing more and more in JSON Schema tools and re-implementing things like product catalogues using JSON Schema and we've never really used any non-standard JSON when using Mongo, so we could get away with fully standard JSON Schema, so if there's only a few core types to add, then please make JSON Schema an option! |
| Comment by Asya Kamsky [ 07/Nov/14 ] |
|
Our documents are extended JSON since we store more types than JSON understands, so I'm not sure any standard will be able to handle it, unless it allows types that are more extensive than what JSON supports. Allowing something like a query that any document going into the collection would have to satisfy seems like the most flexible yet covering all use cases (as long as you can specify if it's strict or minimal - i.e. are fields not in query document allowed or not allowed). |
| Comment by Daniel Coupal [ 07/Nov/14 ] |
|
Closing |
| Comment by Vincent [ 06/Aug/14 ] |
|
IMO https://jira.mongodb.org/browse/SERVER-863 is asking pretty much the same thing (duplicate?) in a more "NoSQL" way. It would be even easier to check if a field exist or not (is it present or not in the hashmap?). |
| Comment by Thomas Rueckstiess [ 06/Aug/14 ] |
|
With such schema templates, we could also look at performance improvements for certain edge cases. For example building a sparse index on a non-existing field would not have to iterate documents in a collection, see |
| Comment by Hari Dosapati [ 15/Apr/14 ] |
|
This a big concern from the maintainance to adapt Mongo DB. In simple terms, we are looking for some thing like this Would like to freeze the schema(collection) and no client should add any unknown property to the collection after that. |
| Comment by Eliot Horowitz (Inactive) [ 20/Apr/12 ] |
|
Not sure we'll do exactly this, but definitely something with similar motivation. |
| Comment by Ben McCann [ 20/Apr/12 ] |
|
Being able to optionally have a schema on some collections would be very nice. |