Friday, 12 June 2020

Need help creating node/mongodb app

Hi All,First of all, apologies if this is not the right sub to ask for help. Please suggest an alternative if not.I'm fairly new to webdev and trying to learn-while-doing. I decided, for a bigger project to get stuck in to, to attempt to create a wedding website for myself and partner. (We're still 12 months away so plenty of time to get things working here!)I've got the main bulk of the work done. Most of the html/css stuff is complete, along with the set up of a mongodb to keep all the invites/rsvp data stored. I have the following rsvp schema:var rsvpSchema = new mongoose.Schema({firstName: String,lastName: String,email: String,attending: Boolean,dietryRequirements: String,songRequest: String});which links to each user account object id using the passport-local-mongoose.This is working fine now, I can create user accounts, save rsvp data on a form, and load/update that data on subsequent log-ins. What I'd like to do, and this is what I'm asking for help with, is to allow multiple 'rsvp' entries per user account. So that any couples/families we invite can have one log-in rather than individual ones per person. I come from a c++/java background where I'd do something like create a 'RsvpData' struct/class with the above fields as properties, then have this object hold an array of RsvpData. From doing some looking around online, it appears thats not the pattern to use with javascript, and maybe even mongoose has its own patterns to consider.Can anyone advise what would be the best way to construct something like this? Rather than storing an array inside a single entry, maybe just have multiple RSVP entries as if they we're separate, but all reference the same user object-id. Would that be the idea? On my RSVP page, I have a form where I believe the 'name' tags on each element correspond to what field of the data model they update (I think i'm remembering that correctly), how would this work if I have multiple people? I was thinking to use an EJS for-loop to create multiple (potentially tabbed) forms for each person, however I'm wondering if the form's tags would get confused as to which entry they should update.I apologise if some of this is a bit stupid or easy, as I said, I'm new to this game and trying to learn as I go along. Thanks in advance for any help!*edit* fixed some typo's. Should learn to proof read!

Submitted June 13, 2020 at 03:43AM by darrensill1304

No comments:

Post a Comment