Search code examples
meteormeteor-collection2

Meteor collection schema: how to turn off data cleaning?


I use the aldeed:collection2 package, and I attached a schema to my Meteor collection. It automatically performs data validation upon every insert/update. However, before inserting anything into the collection, it simply removes data fields that weren't declared in the schema.

I know I can turn this off by specifying filter: false:

MyCollection.insert(newDocument, { filter: false });

But I want it to be turned off by default, so I won't accidentally screw up my database by forgetting to update my schema.

How to turn off data filtering by default?


Solution

  • The .clean method gets always called, as stated in the SimpleSchema docs, therefore I don't think it's possible to disable that by default as you are asking:

    NOTE: The Collection2 package always calls clean before every insert, update, or upsert.