Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda