> Has anyone worked on a way to generate a (tentative) JSON-Schema
> (http://json-schema.org/) from an existing Collection?
Wouldn't that imply that a collection even has a specific schema?
In mongodb every document within a collection can have a different structure so generating a schema
for a collection seems a little bit pointless.
Or am I missing something?
> > Has anyone worked on a way to generate a (tentative) JSON-Schema
> > (http://json-schema.org/) from an existing Collection?
> Wouldn't that imply that a collection even has a specific schema?
> In mongodb every document within a collection can have a different structure so generating a schema
> for a collection seems a little bit pointless.
> Or am I missing something?
I have to be honest, this is the first time I have seen this and since it
is only a draft and not a recognised schema/standard I doubt there has been
much work with MongoDB in relation to this schema type.
On 10 October 2012 12:03, Julien Chaumond <chaum...@gmail.com> wrote:
> Well, the fact that a Collection doesn't need to have a schema doesn't
> mean it can't have a schema, right?
> Julien
> On Oct 10, 11:21 am, Reno Reckling <exi+goo...@wthack.de> wrote:
> > Hi
> > > Has anyone worked on a way to generate a (tentative) JSON-Schema
> > > (http://json-schema.org/) from an existing Collection?
> > Wouldn't that imply that a collection even has a specific schema?
> > In mongodb every document within a collection can have a different
> structure so generating a schema
> > for a collection seems a little bit pointless.
> > Or am I missing something?
> > Regards,
> > Reno
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
> Has anyone worked on a way to generate a (tentative) JSON-Schema > (http://json-schema.org/) from an existing Collection?
Hi Julien,
A few folks have mentioned interest in using JSON Schema Validation but I haven't come across any generic implementations for generating or validating JSON-Schema from MongoDB yet.
Schema.js uses MapReduce to work out the coverage and types of fields in a collection, so you could massage the results from that to generate your JSON Schema. For example, you could infer based on the 'coverage %' whether a field should be optional or required. You could use JSV to validate documents against the expected schema.
I'd be interested to see if anyone does have solutions. The JSON-Schema spec is still an evolving draft so you would definitely be an early adopter ;-).