Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

624
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!