Refactored schemas to make properties all implicitely children
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user