Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda