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

628
Visualizações
Add field to CosmosDB item with Javascript SDK Error: Entity with the specified id does not exist in the system

I am trying to add a new field to a CosmosDB item. The Field i want to add is an object. For example:

jobResult = { 
    description: "exampledescription",
    value: "examplevalue"
}

I tried the following code:

...
const { CosmosClient } = require("@azure/cosmos");
const endpoint = "VALUE";
const key = "VALUE";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: 'VALUE' });
const { container } = await database.containers.createIfNotExists({ id: 'VALUE' });

const operation = [ { op: "Add", path: "/result", value: jobResult } ];
const { resource: updated } = await container.item(id = '42', partitionKeyValue = '/id')
                                             .patch(operation);
...

I get the error:

Entity with the specified id does not exist in the system

The item exists because i get the item when using container.item("42").read()

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

0

The value you have provided for the partitionKeyValue is incorrect.

The code you are currently running is looking for an item with an id of 42 in a container partition of /Id. Instead of providing the path, you will need to provide the value of the partition key, which is set during the creation of the container.

From the looks of your container creation, however, it looks like there is no partitionKey path set, so you shouldn't need to provide it:

...
const { resource: updated } = await container.item(id = '42')
                                             .patch(operation);
...

If you wanted to set the partitionKey, then you would want your container creation to look like this:

...
const { container } = await database.containers.createIfNotExists({
            id: "VALUE",
            partitionKey: "/Id",
});
...

Note: you will likely have to delete your container so that it is recreated with the partition key set.

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