Meteor $jsonSchema support?


I see mongo 3.6 support $jsonSchema.

Would it work if I define a schema on my meteor server side and create a collection, attaching the jsonSchema? It would be cool if the schema is applied at the database level and not higher up at meteor level. For instance, I am also spawning python processes that perform computations and write to mongo, using pymongo. My simpleschema validation only works on the meteor side, but not on the pymongo side. So I do not have a single source of validation at the moment.

I am interested in people’s opinion for using jsonSchema as an alternative to simple-schema. I am also having problems using simple schema with nested arrays (think of the geojson coordinates field [[1,2],[3,4],[5,6]] or [[[1,2],[3,4],[5,6]], [[1,2],[3,4],[5,6]]] etc). So I am thinking of switching over.

That’d be amazing, I was wondering exactly the same
@benjamn is this possible?

The approach I am using is to:

  1. attach the schema to a new mongo database
  2. connect meteor to the schema-aware database

This frees meteor from defining schemas internally for the database.

The only place I still need internal schemas is for validated methods and subscriptions.

It would be nice to see a meteor/validated-method example using jsonschema in the docs. I can write my own validation method, but I am sure there are some power coders, that show a much more elegant example of how to do that.


1 Like