clean document/data in default mut.

This commit is contained in:
Valentin Boettcher 2019-03-10 20:08:14 +01:00
parent 2b1776ff02
commit 922ddc72b0

View file

@ -65,6 +65,9 @@ export const createMutator = async ({
// we don't want to modify the original document
document = data || document;
// clean document
document = collection.simpleSchema().clean(document);
const { collectionName, typeName } = collection.options;
const schema = collection.simpleSchema()._schema;
@ -241,6 +244,9 @@ export const updateMutator = async ({
const { collectionName, typeName } = collection.options;
const schema = collection.simpleSchema()._schema;
// clean data
data = collection.simpleSchema().clean(data);
// OpenCRUD backwards compatibility
selector = selector || { _id: documentId };
data = data || modifierToData({ $set: set, $unset: unset });