diff --git a/lib/links/config.schema.js b/lib/links/config.schema.js index be75a18..cb8043b 100644 --- a/lib/links/config.schema.js +++ b/lib/links/config.schema.js @@ -14,12 +14,7 @@ export default new SimpleSchema({ optional: true }, metadata: { - type: null, - blackbox: true, - optional: true - }, - metadataIdField: { - type: String, + type: Boolean, optional: true }, inversedBy: { diff --git a/lib/links/lib/attachFieldSchema.js b/lib/links/lib/attachFieldSchema.js deleted file mode 100644 index 2ab5808..0000000 --- a/lib/links/lib/attachFieldSchema.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Actually attaches the field schema - * - * @returns {boolean} - * @private - */ -export default (collection, {metadata, field}, isMany) => { - if (metadata) { - if (_.keys(metadata).length) { - const schema = constructMetadataSchema(field, isMany, metadata); - - if (isMany) { - collection.attachSchema({ - [field]: {type: Array, optional: true}, - [field + '.$']: {type: Object}, - ...schema - }) - - } else { - collection.attachSchema({ - [field]: {type: schema}, - ...schema - }) - } - } else { - if (isMany) { - collection.attachSchema({ - [field]: {type: Array, optional: true}, - [field + '.$']: {type: Object, blackbox: true} - }); - } else { - collection.attachSchema({ - [field]: {type: Object, blackbox: true, optional: true} - }); - } - } - } else { - if (isMany) { - collection.attachSchema({ - [field]: {type: Array, optional: true}, - [field + '.$']: {type: String}, - }) - } else { - collection.attachSchema({ - [field]: { - type: String, - optional: true - } - }) - } - } -} - -function constructMetadataSchema(field, isMany, metadataSchema) { - let suffix = isMany ? '.$' : ''; - let schemaDefinition = { - [field + suffix + `._id`]: {type: String} - }; - - _.each(metadataSchema, (value, key) => { - schemaDefinition[field + suffix + '.' + key] = value; - }); - - return schemaDefinition; -} \ No newline at end of file