How to delete an element by its index using mongoose?

I have a model that looks like this:
Member {
memberId: {
type: String,
required: true
},

   customPlaylists:  {
   type: Array,
   default: []
   }
}

In the customPlaylists array I store objects that look like the following:
{ name: ‘playlistName’, urls: } // urls contain strings of YouTube urls

Is there a way to delete a URL from urls array by its index in the array? Should I do something different with my schema in order to do this right?

Hi @Nir_N_A ,

I believe mongoose should allow you to use arrayFilter in its update, therefore you can search in an array filter clause for the relevant playlistName and apply $unset or place empty array on url.

See the following docs for examples:

If mongoose does not support that it is a good excuse to use MongoDB node driver which wr recommend over mongoose…

Thanks
Pavel