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

519
Vistas
find all entries having type_id:ObjectId('random id')

I am trying to repair a mongodb database where in some of the type_id ObjectId got inserted i tried to use regex but this is not working

find({"type_id":{$regex:/ObjectId\(.*\)/}})

Any Suggestion?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Simple version:

db.foo.find({"type_id": {$type: "objectId"}});

Using the agg pipeline. I prefer pipelines because as your expression complexity grows, you don't get bound into the older, smaller feature set of find:

db.foo.aggregate([
    { $match: {$expr: {$eq: [{$type:"$type_id"}, "objectId"]} }}
]);

Look at https://docs.mongodb.com/manual/reference/operator/query/type to find the string values returned by $type.

over 4 years ago · Santiago Trujillo 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