Meteor-Files: Docs say to extend default schema, but default schema is not availble till after creation
I have a suggestion:
Describe your feature / request
Export the default schema so it can be extended before it is passed to the constructor.
How you going to use it? Give a usage example(s)
To simplify the process of extending the default schema in a collection like so:
import { FilesCollection, defaultSchema } from 'meteor/ostrio:files';
import SimpleSchema from 'simpl-schema';
export const Images = new FilesCollection({
collectionName: 'Images',
schema: new SimpleSchema ({
...defaultSchema,
tags: Array,
createdBy: {
type: String,
denyUpdate: true,
denyInsert: true,
optional: true,
autoValue() {
if (this.isInsert) {
return Meteor.userId();
} else if (this.isUpsert) {
return { $setOnInsert: Meteor.userId() };
} else {
this.unset();
}
},
},
}),
});
Images.collection.attachSchema(new SimpleSchema(Images.schema));
Happy to write a PR for this if you’re happy for this to be added
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (14 by maintainers)
Commits related to this issue
- v1.9.3 - Compatibility with `meteor@1.6.0.1` - NPM dependencies update - Fix #531 , thanks to @OliverColeman - Fix #532 , thanks to @menelike - Merge pull request #533 , fix #530 , thanks to @co... — committed to veliovgroup/Meteor-Files by dr-dimitru 7 years ago
- v1.9.6 - Merge #542 - Update (*fix*) default schema, closing #530 , thanks to @coagmano ; - Fix #552 - Fix file's extension on subversions, thanks to @Antony-Eliga ; - Update docs as requested in ... — committed to veliovgroup/Meteor-Files by dr-dimitru 6 years ago
Testing it in an app I’m building now. Everything seems okay. I’ll let it run for a bit before I submit the PR to be sure
Closing, published as
v1.9.6@coagmano merged and published as
v1.9.3Hello @coagmano ,
Great! Let’s dig into it. I suggest to make a
schemaas static property of FilesCollectionServer class. As we expect plain Object, perhaps it should be static getter. Actually I thought it’s already made this way 😛So we will be able:
WDYT?