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

123
Vistas
Remove element in array by its index - mongoose

I have a mongoose model that looks like this:

 Member: {
  memberId: {
    type: String,
    required: true
  },
  customPlaylists: {
    type: Array,
    default: []
  }
       
         }

customPlaylist's array holds object that look like this:

{ name: 'playlist name', urls: [] } // urls array contains url strings

Is there a way using mongoose's updateOne method to remove a url from the urls array by its index in the array? (I use the member's ID in the filter object)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm not sure if there is a straight (1 query) way to do this. But you can try this

<collectionName>.update({}, {$unset : {"urls.<indexNumberHere>" : 1 }}) 
<collectionName>.update({}, {$pull : {"urls" : null}})

There was a ticket to implement this feature and the resolution was Won't Do

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