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

551
Vistas
Remove a Guid(uuid) from a nested list via Mongo DB C# Driver

I have a MongoDB Model which consists of an Id(Guid) and a list of Ids (which are also Guids). Now... for some reason I want to query the list of UserIds and if there is an element with a certain Guid I want to remove it from my Mongo Array.

So here's a part of my model:

public class Model {
        [BsonId]
        [BsonRepresentation(BsonType.String)]
        public Guid Id { get; set; }

        [BsonElement("userIds")]
        public List<Guid> UserIds{ get; set; }
}

and here's the piece of code from the repository where the list of Guids should get an element removed.

var filter = Builders<Models.Event>.Filter.Eq(m => m.Id, someId);
var update = Builders<Models.Event>.Update.PullFilter(m => m.UserIds,
                                                i => i == userId);

await _events.FindOneAndUpdateAsync(filter, update);

In theory, this should work... The problem is Mongo keeps giving me the following error:

"error": "{document} is not supported.",

For some reason, my PullFilter doesn't seem to be able to identify my Guid in the DB.

Here's how the Guid is stored in the DB:

userIds:Array
0:Binary('WYsLZis0RkOeiQ1RNyjzGw==', 3)

Is this a conversion issue? Should I use a string instead of a Guid here? I can't figure out exactly what's happening behind the scenes and why this wouldn't work.

I also tried altering the code to have the Guid be converted to string and check the value against my userId.ToString() but then, i get {document}.ToString() is not supported.

Has anyone encountered this before?

over 4 years 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 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