Skip to content

Instantly share code, notes, and snippets.

@mikeymaio
Created January 13, 2017 22:02
Show Gist options
  • Save mikeymaio/ba52e0d8e697ea29e0ba1b0b1071e224 to your computer and use it in GitHub Desktop.
Save mikeymaio/ba52e0d8e697ea29e0ba1b0b1071e224 to your computer and use it in GitHub Desktop.
Capstone 2 : Getting Specific With Database / Models / Schemas
BandMom / Roadie
Functions for MVP:
User login
User logout
User CRUD {
}
Event CRUD {
create event
save event
update event
delete event
}
create => {
venueName: '',
venueAddress: '',
startTime: '',
soundCheckTime: '',
manifest: {
cables:{
quarterInch: {
description: '',
quantity: '',
questionId: ''
},
XLR: {
description: '',
quantity: '',
questionId: ''
},
power: {
description: '',
quantity: '',
questionId: ''}
}
misc: {
questionId: '',
items: [{
description: '',
quantity: ''
}]
}
}
}
@douglas-mason
Copy link

`
Thinkful-Mike-BandMom-Data-Models

Models:

// Schemas
const User = {
   firstName: string,
   lastName: string,
   userName: string,
   password: string,
   hash: string,
   salt: string,
   email: string,
   phone: string
};

const Event = {
   venueName: string,
   venueAddress: string,
   startTime: Date,
   soundCheckTime: Date,
   manifest: Object
   userId: ObjectId(); // The user id of the user that made the event
};
// End Schemas

// Client models
const manifestItem = {
   id: int,
   name: string,
   description: string,
   category: string,
   quantity: int
};

const question = {
   id: int,
   text: string,
   manifestItem: manifestItem,
   nextQuestionId: int // optional
}
const bandEvent = {};
const bandEvent.venueName = req.body.venueName;
//...etc

//the last event created for user
db.Events.find({userId: currentUserId}).sort({_id: -1}).limit(1);

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment