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

183
Visualizações
Create a nested object in CosmosDB (Js)

Building a react native app using CosmosDB and it's SQL api.

Per their documentation, I can add an object to a container like this:

const CosmosClient = require('@azure/cosmos').CosmosClient;

const client = new CosmosClient({ endpoint, key });

const myNewObject = {foo: "bar"}

 await client
.database(databaseId)
.container(containerId)
.items.create(myNewObject);

And I can confirm this works.

What I'm trying to do tho, is place data into that {foo: "bar"} document that already exists. So far I've tried chaining the .item method, but it does't work.

 await client
.database(databaseId)
.container(containerId)
.item(idOfMyNewObject) // The existing object I want to create a child in
.item('myNewChildObject') // new child of the parent
.create(newEntry); // new entry in the new child

Any ideas? the documentation doesn't seem to talk about this.

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

0

There's no method on the container that does this for you. You must define the structure of the data yourself in your code. Here is an example of a customer record which has both an array of addresses as well as an embedded object.

const customer = {
"id": "000242A2-BF40-4220-864B-2770CAA38F5D",
"type": "customer",
"customerId": "000242A2-BF40-4220-864B-2770CAA38F5D",
"title": "",
"firstName": "Timothy",
"lastName": "Kelly",
"emailAddress": "timothy4@adventure-works.com",
"phoneNumber": "193-555-0189",
"creationDate": "2014-03-14T00:00:00",
"addresses": [
    {
        "addressLine1": "9918 Scottsdale Rd.",
        "addressLine2": "",
        "city": "Novato",
        "state": "CA ",
        "country": "US",
        "zipCode": "94947",
        "location": {
            "type": "Point",
            "coordinates": [
                -122.764,
                38.0852
            ]
        }
    }
],
"password": {
    "hash": "LvEbgjonEPU11HEeSXqdzTsmqNeUfuhxBNL82vGlCWA=",
    "salt": "61626BAE"
},
"salesOrderCount": 1
}
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