added API for removing collection fields

This commit is contained in:
Sacha Greif 2015-04-27 10:30:47 +09:00
parent 0a328034ff
commit f39e6b8626

View file

@ -13,6 +13,19 @@ Meteor.Collection.prototype.registerField = function (field) {
collection.attachSchema(fieldSchema);
}
/**
* Remove a field from a schema.
* @param {String} fieldName
*/
Meteor.Collection.prototype.removeField = function (fieldName) {
var collection = this;
var schema = _.omit(collection.simpleSchema()._schema, fieldName);
// add field schema to collection schema
collection.attachSchema(schema, {replace: true});
}
/**
* Global schemas object
* @namespace Telescope.schemas