Skip to content

Instantly share code, notes, and snippets.

@sferoze
Last active September 23, 2015 22:48
Show Gist options
  • Save sferoze/cbcf131be5e66a2f7748 to your computer and use it in GitHub Desktop.
Save sferoze/cbcf131be5e66a2f7748 to your computer and use it in GitHub Desktop.
stridepostUserSchema
// SHARED SCHEMA FOR BOTH ADULT AND CHILD. PROFILE CONTAINS KEYS FOR BOTH ADULT AND CHILD
// SOME KEYS ARE ONLY RELAVANT TO ADULT AND SOME ONLY TO CHILD
// BUT SINCE THEY ARE ALL USERS WE HAVE TO SHARE THE SAME SCHEMA
// SO MANY KEYS IN PROFILE ARE MARKED AS OPTIONAL.
Schema.UserProfile = new SimpleSchema(
firstName:
type: String
regEx: /^[a-zA-Z-]{2,25}$/
optional: true
lastName:
type: String
regEx: /^[a-zA-Z]{2,25}$/
optional: true
birthday:
type: Date
optional: true
gender:
type: String
allowedValues: [
'male'
'female'
]
optional: true
profilePhotoURL:
type: String
optional: true
promoCode:
type: String
optional: true
token:
type: String
optional: true
color:
type: String
optional: true
weeklyBudget:
type: Number
optional: true
autoAllowancePercent:
type: Number
optional: true
allowOnlineRewardSearch:
type: Boolean
optional: true
activateOnlineRewards:
type: Boolean
optional: true
useKidFilters:
type: Boolean
optional: true
timeZone:
type: String
optional: true
phone:
type: Object
optional: true
'phone.home':
type: String
optional: true
role:
type: String
optional: true
)
Schema.User = new SimpleSchema(
username:
type: String
regEx: /^[a-z0-9A-Z_]{3,15}$/
emails:
type: [ Object ]
optional: true
'emails.$.address':
type: String
regEx: SimpleSchema.RegEx.Email
'emails.$.verified': type: Boolean
createdAt: type: Date
profile:
type: Schema.UserProfile
optional: true
services:
type: Object
optional: true
blackbox: true
roles:
type: Object
optional: true
blackbox: true
roles:
type: [ String ]
optional: true
families:
type: [Object]
'families.$.familyId':
type: String
'families.$.admin':
type: Boolean
optional: true
'families.$.points':
type: Number
optional: true
'families.$.pendingPoints':
type: Number
optional: true
showWelcome:
type: Boolean
defaultValue: true
createdAt:
type: Date
)
// EXAMPLE ADULT USER DOCUMENT
{
"_id": "22ENRxiZckoEsv7DJ",
"emails": [
{
"address": "[email protected]",
"verified": true
}
],
"families": [
{
"familyId": "i5i4wtwJhd2fEJrdS",
"admin": true
}
],
"profile": {
"firstName": "Feroze",
"lastName": "Shahpurwala",
"birthday": "2011-06-14T04:00:00.000Z",
"role": "Father",
"timeZone": "EST",
"phone": {
"home": "734-888-0943"
},
"profilePhotoURL": "https://stridepost-uploads-dev.s3.amazonaws.com/users/22ENRxiZckoEsv7DJ/profilePhoto_22ENRxiZckoEsv7DJ.jpeg",
"color": "#833737"
},
"roles": [
"adult",
"family-admin",
"stridepost-admin",
"admin"
],
"showWelcome": true,
"username": "test"
}
// EXAMPLE CHILD USER DOCUMENT
{
"_id": "5T8uJczqhHBXs7zxP",
"emails": [
{
"address": "[email protected]",
"verified": false
}
],
"families": [
{
"familyId": "i5i4wtwJhd2fEJrdS",
"points": 45
}
],
"profile": {
"firstName": "kate",
"lastName": "twist",
"grade": "8",
"gender": "male",
"timeZone": "EST",
"phone": {
"home": "464-634-4437"
},
"weeklyBudget": "30",
"autoAllowancePercent": "40.00",
"birthday": "2015-06-23T04:00:00.000Z",
"allowOnlineRewardSearch": true,
"activateOnlineRewards": true,
"color": "#903838",
"profilePhotoURL": "https://stridepost-uploads-dev.s3.amazonaws.com/users/5T8uJczqhHBXs7zxP/profilePhoto_5T8uJczqhHBXs7zxP_1439396823.jpeg"
},
"roles": [
"child"
],
"showWelcome": true,
"username": "lemon"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment