Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

547
Visualizações
In DymanoDB/Dynamoose, how can I set a schema of a map of string keys and number values?

So I have this instructions:

Schema Defs: Result object: It's a map of string keys and number values

"result": { "M": { [STRING]: { "N": "401" } },

This is what I have so far

  result: {
    type: Object,
    schema: {
      // I am getting 2 errors:
      // Parsing error: Unexpected token, expected "]"
      // ',' expected.
      [id: String]: Number
    },
    required: true
  },

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

[id: String] is a TypeScript thing. Not allowed in standard JavaScript.

This is not technically possible in Dynamoose. The only option here is to use the saveUnknown schema setting.

This was brought up in a conversation before, and the user who wanted to do this I told to create an issue on the GitHub repo but it doesn't look like that happened. If you'd like support for this in Dynamoose in the future, please submit a feature request on the GitHub repo.


Edit

In order to do this your schema would looks something like:

new dynamoose.Schema({
  result: {
    type: Object,
    required: true
  },
}, {
  "saveUnknown": ["result.**"]
});

This will allow indefinitely nested objects within result.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda