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

138
Vistas
Can't query by ID as second parameter with AWS DataStore

I am total noob to AWS, DataStore, and DynamoDB. I can't figure out why this isn't working.

If I attempt query an object related to my users ID from Cognito this seems to work. If I console log I get an array with one User.

    let profile = await DataStore.query(User, (u) =>
      u.id('eq', user.attributes.sub)
    );

    // Returns [Model]
    console.log('[LOADING USER DATA]', profile);

If I attempt query an object related to my users ID like this. (as recommended by the docs). I get undefined.

    let profile = await DataStore.query(User, user.attributes.sub);

    // Returns undefined
    console.log('[LOADING USER DATA]', profile);

Dynamo Data looks fine to me but am I using the wrong primary key ID field or something?

{
 "id": "929e6e62-e3a0-4b84-b050-72c53eebda93",
 "_lastChangedAt": 1644433699,
 "status": "Active",
 "createdAt": "2022-02-09T19:08:18.548Z",
 "name": "Test",
 "orgs": [
  "b6508155-f5cf-49b7-88d6-0e605677c4e4"
 ],
 "_version": 1,
 "role": "User",
 "updatedAt": "2022-02-09T19:08:18.548Z",
 "orgID": "b6508155-f5cf-49b7-88d6-0e605677c4e4",
 "title": ""
}

What am I doing wrong?

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