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

266
Visualizações
Why is putting an object in local dynamodb table changing some field of the said object?

This is an extremely weird one. I'm using datamapper for dynamo and dynamolocal in typescript to test my stuff. For some reason it overwrites one object field and I can't figure out why.

I'm seeding the table like so:

private async seedTable() {
        // FIRST PART
        for (const obj of [...objects]) {
            const toSave = new MyObject().fromPartial({
                ...obj
            });
            console.log(`myBool: ${toSave.myBool}`);
            await this.ddbMapper.put(toSave);
        }

        // SECOND PART
        await this.ddbMapper.put(
            new MyObject().fromPartial({
                ...objects[0],
                objId: "test",
                myBool: false
            })
        );
    }

In this previous snippet, the objects from the for loop will print: "myBool: false"

however in the table they will be true (what?)

the second part where I hardcode the object, it's getting saved with myBool: false as I would expect

If I overwrite the value it works but if I keep the original object it switches to true for no apparent reason.

this is the fromPartial implementation

public fromPartial(data: Partial<MyObject>): MyObject {
        Object.assign(this, data);
        return this;
    }

is this a bug from dynamodb / dynamodb-local / my implementation / javascript / typescript ? does anybody have a clue into what could be the source of the issue ?

Edit: ddbmapper is the DataMapper class from dynamodb-data-mapper

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

0

Ok found the issue, actually the value was "false" instead of false which the mapper seems to force at runtime so the string evaluates to true. Kind of a weird behaviour when you know that passing an object with correct properties but no type does not work with datamapper : the github issue I'm talking about issue

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