mirror of
https://github.com/vale981/Vulcan
synced 2025-03-11 21:16:40 -04:00
67 lines
1.3 KiB
JavaScript
67 lines
1.3 KiB
JavaScript
/*
|
|
|
|
A SimpleSchema-compatible JSON schema
|
|
|
|
*/
|
|
|
|
import FormsUpload from 'meteor/vulcan:forms-upload';
|
|
|
|
const schema = {
|
|
|
|
// default properties
|
|
|
|
_id: {
|
|
type: String,
|
|
optional: true,
|
|
viewableBy: ['guests'],
|
|
},
|
|
createdAt: {
|
|
type: Date,
|
|
optional: true,
|
|
viewableBy: ['guests'],
|
|
onInsert: (document, currentUser) => {
|
|
return new Date();
|
|
}
|
|
},
|
|
userId: {
|
|
type: String,
|
|
optional: true,
|
|
viewableBy: ['guests'],
|
|
resolveAs: {
|
|
fieldName: 'user',
|
|
type: 'User',
|
|
resolver(pic, args, context) {
|
|
return context.Users.findOne({ _id: pic.userId }, { fields: context.Users.getViewableFields(context.currentUser, context.Users) });
|
|
},
|
|
addOriginalField: true
|
|
}
|
|
},
|
|
|
|
// custom properties
|
|
|
|
imageUrl: {
|
|
label: 'Image URL',
|
|
type: String,
|
|
viewableBy: ['customers'],
|
|
insertableBy: ['members'],
|
|
editableBy: ['members'],
|
|
control: FormsUpload, // use the FormsUpload form component
|
|
form: {
|
|
options: {
|
|
preset: 'vulcanstagram'
|
|
},
|
|
}
|
|
},
|
|
body: {
|
|
label: 'Body',
|
|
type: String,
|
|
optional: true,
|
|
control: 'textarea', // use a textarea form component
|
|
viewableBy: ['guests'],
|
|
insertableBy: ['members'],
|
|
editableBy: ['members']
|
|
},
|
|
|
|
};
|
|
|
|
export default schema;
|