Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

108
Vistas
Mongodb upsert into embedded array

Here is my document schema:

  var UserSchema = new mongoose.Schema({
      username: {type: String, lowercase: true, unique: true},
      email: {type:String, unique: true},
      currentSquads: [{seriesId: String, squad: [String]}]
});

Given a _id(for the UserSchema document), seriesId and squad: I would like to update the user document with the new squad if the seriesId already exists in the currentSquads array, otherwise add a new object in the currentSquad array.

What is the best way to do this in Mongoose?

8 months ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.