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

326
Vistas
Mongoose best way to store a set of ids in a document? Map? Array?

I have a table Entries where each document represents a list entry. Among other info, I want to store a set of id's in each document. These id's will be strings. The relevant id's needed will vary between different documents. When these documents are retrieved, the goal is to be able to efficiently display the entries in a React table and filter by the id's each document has, which seems like would make the most sense as a javascript Set.

Example of what I'm thinking of:

{
  name: "Bob",
  ids: {
    "1234a",
    "9999b"
  }
},
{
  name: "Paul",
  ids: {
    "9999b",
    "0000z"
  }
}

From reading around, it looks like I could potentially store ids as an Array, and convert them to a Set when retrieved.

Another options seems to be to store ids as a Map, where the key is the id and the value is something arbitrary (like true or something). Example:

{
  name: "Paul",
  ids: {
    "9999b": true,
    "0000z": true
  }
}

What would be the most performant way to do this?

about 4 years ago · Juan Pablo Isaza
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