Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
How to implement multiple users in my to do app (MERNstack)?

I am trying to implement multiple users for my to do app, but im unsure of the best approach. Basically, i want to allow users to register and login, and only CRUD lists and tasks for their account.

One idea I had was to create a document per user and the data would look like:

{
user: "john doe",
password: "qwerty",
_id: ObjectID("1234567890"),
lists:[
   {title: "school",
    tasks: ["math", "english", "science"]
   },
   {title: "work",
    tasks: ["budget", "presentation", "excel"]
   }
]

is there an alternative approach? Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I understand you correctly, and from what I can see you listed mongoose as a tag, so I'm assuming you are implementing it. Create a User model:

const userSchema = new Schema({
   username: {
      type: String,
      required: true
   },
   password: {
      type: String,
      required: true
   }
})

Then you need to figure out if you want to store lists in the document, or if you want to reference them (meaning you put the lists in different documents and attach the id to user). You will then need to create the user routes, where users can be created, and deleted. you will also want to implement a login. You will then need to create authentication using something like express-jwt and jsonwebtoken where tokens will be sent back and forth from your api and the client. By creating the model and the routes, multiple users can be created.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!