2017-10-18 20:05:51 +09:00
|
|
|
import moment from 'moment';
|
2017-05-31 10:25:13 +09:00
|
|
|
|
|
|
|
const schema = {
|
|
|
|
|
|
|
|
// default properties
|
|
|
|
|
|
|
|
_id: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
viewableBy: ['guests'],
|
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
type: Date,
|
|
|
|
optional: true,
|
|
|
|
viewableBy: ['guests'],
|
|
|
|
onInsert: (document, currentUser) => {
|
|
|
|
return new Date();
|
2018-02-03 13:17:04 -06:00
|
|
|
},
|
2017-05-31 10:25:13 +09:00
|
|
|
},
|
|
|
|
userId: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
viewableBy: ['guests'],
|
|
|
|
},
|
|
|
|
|
|
|
|
// custom properties
|
|
|
|
|
2017-10-18 20:05:51 +09:00
|
|
|
associatedCollection: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
associatedId: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
},
|
|
|
|
|
2017-05-31 10:25:13 +09:00
|
|
|
tokenId: {
|
|
|
|
type: String,
|
|
|
|
optional: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
productKey: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
optional: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
test: {
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
data: {
|
|
|
|
type: Object,
|
2018-01-02 13:05:34 +09:00
|
|
|
viewableBy: ['guests'],
|
2017-05-31 10:25:13 +09:00
|
|
|
blackbox: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
type: Object,
|
|
|
|
blackbox: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
ip: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
},
|
|
|
|
|
2017-10-18 20:05:51 +09:00
|
|
|
// GraphQL only
|
|
|
|
|
|
|
|
createdAtFormatted: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
2018-01-02 13:05:34 +09:00
|
|
|
viewableBy: ['guests'],
|
2017-10-18 20:05:51 +09:00
|
|
|
resolveAs: {
|
|
|
|
type: 'String',
|
|
|
|
resolver: (charge, args, context) => {
|
|
|
|
return moment(charge.createdAt).format('dddd, MMMM Do YYYY');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-09 11:30:15 +09:00
|
|
|
createdAtFormattedShort: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
viewableBy: ['guests'],
|
|
|
|
resolveAs: {
|
|
|
|
type: 'String',
|
|
|
|
resolver: (charge, args, context) => {
|
2018-02-14 22:21:56 +09:00
|
|
|
return moment(charge.createdAt).format('YYYY/MM/DD, hh:mm');
|
2018-02-09 11:30:15 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-18 20:05:51 +09:00
|
|
|
stripeChargeUrl: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
2018-01-02 13:05:34 +09:00
|
|
|
viewableBy: ['guests'],
|
2017-10-18 20:05:51 +09:00
|
|
|
resolveAs: {
|
|
|
|
type: 'String',
|
|
|
|
resolver: (charge, args, context) => {
|
|
|
|
return `https://dashboard.stripe.com/payments/${charge.data.id}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-05-31 10:25:13 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
export default schema;
|