Refactored schemas to make properties all implicitely children

This commit is contained in:
Stefan Zermatten
2019-04-03 12:38:01 +02:00
parent 28ffcc87b4
commit 681e669e76
19 changed files with 37 additions and 62 deletions

View File

@@ -1,15 +1,7 @@
import SimpleSchema from 'simpl-schema';
import schema from '/imports/api/schema.js';
const RefSchema = new SimpleSchema({
id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
index: 1
},
collection: {
type: String
},
const inhertitedFieldsSchema = new SimpleSchema({
name: {
type: String,
optional: true,
@@ -21,6 +13,19 @@ const RefSchema = new SimpleSchema({
},
});
const RefSchema = new SimpleSchema({
id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
index: 1
},
collection: {
type: String
},
});
RefSchema.extend(inhertitedFieldsSchema);
let ChildSchema = schema({
parent: {
type: RefSchema,
@@ -35,9 +40,7 @@ let ChildSchema = schema({
},
});
const inheritedFields = new Set(RefSchema.objectKeys());
inheritedFields.delete('id');
inheritedFields.delete('collection');
const inheritedFields = new Set(inhertitedFieldsSchema.objectKeys());
export default ChildSchema;
export { inheritedFields };