add note link to issue in collection2 on mutation insert, remove debug console logs on mutation edit

This commit is contained in:
xavcz 2017-01-11 10:54:39 +01:00
parent e894c3224c
commit 7a15103de7

View file

@ -71,7 +71,9 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
document = runCallbacks(`${collectionName}.new.sync`, document, currentUser);
// add _id to document
document._id = collection.insert({...document}); // use {...document} to "enable" Object.prototype (see https://cl.ly/1N1m2d0y3u1A)
// note: use {...document} to "enable" Object.prototype (see https://cl.ly/1N1m2d0y3u1A)
// see https://github.com/aldeed/meteor-collection2-core/issues/8
document._id = collection.insert({...document});
// get fresh copy of document from db
const newDocument = collection.findOne(document._id);
@ -108,15 +110,12 @@ export const editMutation = ({ collection, documentId, set, unset, currentUser,
// check that the current user has permission to edit each field
const modifiedProperties = _.keys(set).concat(_.keys(unset));
modifiedProperties.forEach(function (fieldName) {
var field = schema[fieldName];
console.log(field);
const field = schema[fieldName];
if (!context.Users.canEditField(currentUser, field, document)) {
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
}
});
console.log(modifier);
// validate modifier against schema
collection.simpleSchema().namedContext(`${collectionName}.edit`).validate(modifier, {modifier: true});