SubSchema = new SimpleSchema({
name: {
type: String,
},
});
MainSchema = new SimpleSchema({
// ..
subschema: {
type: SubSchema,
},
// ..
});
// BUG BUG BUG
// Pick does NOT work as excpected
// .. this only returns a FLAT object, with NO "name"-field attached
AnotherSchema = MainSchema.pick(['subschema']);
// Note: .pick(['subschema', 'subschema.$']); does NOT help
Thanks for your feedback… unfortunatly this is not what I want to achieve as it embedds SubSchema’s fields into the root of MainSchema (for example like PickedSchema.name).
I actually need to embedd SubSchema’s fields into an extra dedicated field called ‘subschema’, like PickedSchema.subschema.name.
… something like this would work (but is not what I need to have as illustrated above).
SubSchema = new SimpleSchema({
name: {
type: String,
},
});
MainSchema = new SimpleSchema([
SubSchema, // this embedds SubSchema's fields into the root of MainSchema
// p.e. like ``MainSchema.name``
//
// BUT I need to have it in an extra field,
// p.e. like ``MainSchema.subschema.name``
]);
PickedSchmema = MainSchema.pick(['name']);
This is something I’ve already fixed in simple-schema v2 (work in progress), but because it would not be backwards compatible to change it, I’m not fixing in v1.