{"id":2326,"date":"2016-07-07T15:18:31","date_gmt":"2016-07-07T15:18:30","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=2326"},"modified":"2025-06-13T21:09:44","modified_gmt":"2025-06-14T04:09:44","slug":"using-the-couchbase-sub-document-api-with-the-golang-sdk","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/es\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","title":{"rendered":"Uso de la API de subdocumentos de Couchbase con el SDK de GoLang"},"content":{"rendered":"<p>No hace mucho escrib\u00ed sobre c\u00f3mo trabajar con partes, o fragmentos, de documentos en Couchbase<br \/>\n<a href=\"https:\/\/www.couchbase.com\/blog\/es\/using-the-couchbase-sub-document-api-with-the-nodejs-sdk\/\">utilizando el SDK de Node.js<\/a>. Ser capaz de trabajar con<br \/>\npartes de los documentos es posible utilizando<br \/>\n<a href=\"https:\/\/developer.couchbase.com\/server\/?utm_source=blogs&amp;utm_medium=link&amp;utm_campaign=blogs\">Servidor Couchbase<\/a> 4.5 y superiores y el subdocumento API.<br \/>\nEsto es enorme porque cuando se trabaja con documentos NoSQL puede encontrarse con documentos muy grandes debido a todos los datos JSON incrustados. Como probablemente<br \/>\nsabe, hacer peticiones en documentos grandes es lento, y en la era moderna de la web, todo tiene que ser r\u00e1pido. En su lugar, es m\u00e1s eficiente s\u00f3lo<br \/>\ntrabaja con lo que necesitas y no con todo a la vez.<\/p>\n<p>En esta ocasi\u00f3n vamos a ver c\u00f3mo hacer las mismas manipulaciones de documentos NoSQL que vimos en Node.js, pero esta vez con el lenguaje de programaci\u00f3n Go. Vamos a<br \/>\nelabore una historia de datos para este ejemplo. Ser\u00e1 la misma historia de datos que en el ejemplo anterior, pero supongamos que tenemos el siguiente documento JSON:<\/p>\n<pre><code>\r\n{\r\n    firstName: \"Nic\",\r\n    lastName: \"Raboy\",\r\n    socialNetworking: {\r\n        twitter: \"nraboy\"\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>Los datos anteriores ser\u00e1n una base <a href=\"https:\/\/www.couchbase.com\/blog\/es\/user-profile-store-advanced-data-modeling\/\">almac\u00e9n de perfiles de usuario<\/a> con la informaci\u00f3n de las redes sociales. Todas nuestras manipulaciones ser\u00e1n en torno a la informaci\u00f3n de los medios sociales, no<br \/>\nlos datos padre que lo rodean.<\/p>\n<p>Para mantener las cosas simples en esta gu\u00eda, vamos a trabajar con un proyecto nuevo. En este punto asumiremos que tienes Couchbase Server 4.5+ y<br \/>\nGoLang instalado y configurado en tu m\u00e1quina. Si a\u00fan no has descargado el SDK de GoLang para Couchbase, ejecuta lo siguiente desde tu Comando<br \/>\nPrompt o Terminal:<\/p>\n<pre><code>\r\ngo get github.com\/couchbase\/gocb\r\n<\/code><\/pre>\n<p>Todo nuestro proyecto para este ejemplo residir\u00e1 en un \u00fanico archivo. Nos referiremos a este archivo como <strong>main.go<\/strong> y puede residir en cualquier<br \/>\nDirectorio de proyectos Go que desee siempre que cumpla los requisitos del lenguaje de programaci\u00f3n Go.<\/p>\n<p>Para empezar, vamos a crear un archivo <code>principal<\/code> dentro de nuestro proyecto:<\/p>\n<pre><code>\r\nfunc main() {\r\n fmt.Println(\"Starting the app...\")\r\n cluster, _ := gocb.Connect(\"couchbase:\/\/localhost\")\r\n bucket, _ = cluster.OpenBucket(\"default\", \"\")\r\n person := Person{FirstName: \"Nic\", LastName: \"Raboy\", SocialNetworking: &amp;SocialNetworking{Twitter: \"nraboy\"}}\r\n createDocument(\"nraboy\", &amp;person)\r\n}\r\n<\/code><\/pre>\n<p>Hay algunas cosas a tener en cuenta en lo anterior. En primer lugar, estamos estableciendo una conexi\u00f3n con un cl\u00faster de Couchbase que se ejecuta localmente. Cuando la conexi\u00f3n tiene<br \/>\nestablecido abrimos el <code>por defecto<\/code> cubo. Observe que s\u00f3lo estamos asignando un valor a la variable <code>cubo<\/code> y no definirlo. Este<br \/>\nes porque vamos a utilizar esta variable de forma global y debemos definirla fuera del archivo <code>principal<\/code> funci\u00f3n. Con el cubo abierto, vamos a<br \/>\ncrear nuestra estructura de datos inicial. Esta estructura de datos <code>Persona<\/code> se define a continuaci\u00f3n:<\/p>\n<pre><code>\r\ntype Person struct {\r\n FirstName        string            `json:\"firstname,omitempty\"`\r\n LastName         string            `json:\"lastname,omitempty\"`\r\n SocialNetworking *SocialNetworking `json:\"socialNetworking,omitempty\"`\r\n}\r\n\r\ntype SocialNetworking struct {\r\n Twitter string `json:\"twitter,omitempty\"`\r\n Website string `json:\"website,omitempty\"`\r\n}\r\n<\/code><\/pre>\n<p>En <code>Persona<\/code> tendr\u00e1 la informaci\u00f3n b\u00e1sica del usuario y har\u00e1 referencia a otra estructura llamada <code>Redes sociales<\/code>. Ambos<br \/>\nse etiquetan con nombres de propiedades JSON que deben excluirse de la impresi\u00f3n si est\u00e1n en blanco.<\/p>\n<p>Volviendo a la <code>principal<\/code> funci\u00f3n. Observa que a nuestro nuevo objeto persona le falta la p\u00e1gina web. Lo a\u00f1adiremos m\u00e1s adelante. El primer objeto<br \/>\nque llamamos desde la funci\u00f3n <code>principal<\/code> se llama a la funci\u00f3n <code>crearDocumento<\/code> y a\u00f1adir\u00e1 nuestro objeto a la base de datos. Esta funci\u00f3n<br \/>\nse define del siguiente modo:<\/p>\n<pre><code>\r\nfunc createDocument(documentId string, person *Person) {\r\n fmt.Println(\"Upserting a full document...\")\r\n _, error := bucket.Upsert(documentId, person, 0)\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n getDocument(documentId)\r\n getSubDocument(documentId)\r\n}\r\n<\/code><\/pre>\n<p>En la funci\u00f3n anterior a\u00fan no estamos trabajando con fragmentos de un documento. Necesitamos empezar el ejemplo con datos frescos primero. Vamos a insertar<br \/>\nel documento inicial y siempre que no haya errores vamos a llamar a <code>getDocument<\/code> para validar su creaci\u00f3n y, a continuaci\u00f3n<br \/>\n<code>getSubDocument<\/code> para obtener una parte determinada del documento. El sitio <code>getDocument<\/code> se utilizar\u00e1 dos veces en esta aplicaci\u00f3n y<br \/>\nparece lo siguiente:<\/p>\n<pre><code>\r\nfunc getDocument(documentId string) {\r\n fmt.Println(\"Getting the full document by id...\")\r\n var person Person\r\n _, error := bucket.Get(documentId, &amp;person)\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n jsonPerson, _ := json.Marshal(&amp;person)\r\n fmt.Println(string(jsonPerson))\r\n}\r\n<\/code><\/pre>\n<p>En el <code>getDocument<\/code> estamos obteniendo el documento completo basado en id, marshalling en JSON, y luego imprimirlo. Este<br \/>\nnos lleva a la <code>getSubDocument<\/code> como se ve a continuaci\u00f3n:<\/p>\n<pre><code>\r\nfunc getSubDocument(documentId string) {\r\n fmt.Println(\"Getting part of a document by id...\")\r\n fragment, error := bucket.LookupIn(documentId).Get(\"socialNetworking\").Execute()\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n var socialNetworking SocialNetworking\r\n fragment.Content(\"socialNetworking\", &amp;socialNetworking)\r\n jsonSocialNetworking, _ := json.Marshal(&amp;socialNetworking)\r\n fmt.Println(string(jsonSocialNetworking))\r\n upsertSubDocument(documentId, \"thepolyglotdeveloper.com\")\r\n}\r\n<\/code><\/pre>\n<p>En el <code>getSubDocument<\/code> estamos haciendo una b\u00fasqueda dentro de un documento para una propiedad espec\u00edfica. Aqu\u00ed es donde empezamos a trabajar con<br \/>\nla API de subdocumentos. La b\u00fasqueda que estamos realizando es una b\u00fasqueda del subdocumento <code>redes sociales<\/code> propiedad. Tenga en cuenta que me estoy refiriendo a la JSON, no<br \/>\nel <code>struct<\/code> nombre. Cuando tengamos el fragmento podemos marshalizarlo en JSON y luego imprimirlo. El resultado deber\u00eda tener este aspecto:<\/p>\n<pre><code>\r\n{\r\n    \"twitter\": \"nraboy\"\r\n}\r\n<\/code><\/pre>\n<p>Al final del <code>getSubDocument<\/code> hacemos una llamada a una funci\u00f3n que pronto se crear\u00e1 <code>upsertSubDocument<\/code> funci\u00f3n. Aqu\u00ed es donde<br \/>\nvamos a modificar parte de un documento sin obtener antes el documento completo. Esta funci\u00f3n se puede ver de la siguiente manera:<\/p>\n<pre><code>\r\nfunc upsertSubDocument(documentId string, website string) {\r\n fmt.Println(\"Upserting part of a document...\")\r\n _, error := bucket.MutateIn(documentId, 0, 0).Upsert(\"socialNetworking.website\", website, true).Execute()\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n getDocument(documentId)\r\n}\r\n<\/code><\/pre>\n<p>En la funci\u00f3n anterior primero especificamos qu\u00e9 documento queremos manipular bas\u00e1ndonos en el id del documento. A continuaci\u00f3n, decimos que queremos realizar un upsert en un<br \/>\ncierta ruta o propiedad del documento. En este ejemplo estamos diciendo que queremos upsert un <code>sitio web<\/code> que se encuentra en la propiedad<br \/>\n<code>redes sociales<\/code> padre. Tenga en cuenta que todo este proceso se realiza sin obtener realmente el documento.<\/p>\n<p>Cuando hayamos terminado, volvemos a buscar el documento completo para ver qu\u00e9 aspecto tiene en su conjunto. En caso de que necesites que esto se ponga en perspectiva un<br \/>\npoco mejor, el c\u00f3digo completo de este proyecto se puede ver a continuaci\u00f3n:<\/p>\n<pre><code>\r\npackage main\r\n\r\nimport (\r\n \"encoding\/json\"\r\n \"fmt\"\r\n\r\n \"github.com\/couchbase\/gocb\"\r\n)\r\n\r\nvar bucket *gocb.Bucket\r\n\r\ntype Person struct {\r\n FirstName        string            `json:\"firstname,omitempty\"`\r\n LastName         string            `json:\"lastname,omitempty\"`\r\n SocialNetworking *SocialNetworking `json:\"socialNetworking,omitempty\"`\r\n}\r\n\r\ntype SocialNetworking struct {\r\n Twitter string `json:\"twitter,omitempty\"`\r\n Website string `json:\"website,omitempty\"`\r\n}\r\n\r\nfunc getDocument(documentId string) {\r\n fmt.Println(\"Getting the full document by id...\")\r\n var person Person\r\n _, error := bucket.Get(documentId, &amp;person)\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n jsonPerson, _ := json.Marshal(&amp;person)\r\n fmt.Println(string(jsonPerson))\r\n}\r\n\r\nfunc createDocument(documentId string, person *Person) {\r\n fmt.Println(\"Upserting a full document...\")\r\n _, error := bucket.Upsert(documentId, person, 0)\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n getDocument(documentId)\r\n getSubDocument(documentId)\r\n}\r\n\r\nfunc getSubDocument(documentId string) {\r\n fmt.Println(\"Getting part of a document by id...\")\r\n fragment, error := bucket.LookupIn(documentId).Get(\"socialNetworking\").Execute()\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n var socialNetworking SocialNetworking\r\n fragment.Content(\"socialNetworking\", &amp;socialNetworking)\r\n jsonSocialNetworking, _ := json.Marshal(&amp;socialNetworking)\r\n fmt.Println(string(jsonSocialNetworking))\r\n upsertSubDocument(documentId, \"thepolyglotdeveloper.com\")\r\n}\r\n\r\nfunc upsertSubDocument(documentId string, website string) {\r\n fmt.Println(\"Upserting part of a document...\")\r\n _, error := bucket.MutateIn(documentId, 0, 0).Upsert(\"socialNetworking.website\", website, true).Execute()\r\n if error != nil {\r\n  fmt.Println(error.Error())\r\n  return\r\n }\r\n getDocument(documentId)\r\n}\r\n\r\nfunc main() {\r\n fmt.Println(\"Starting the app...\")\r\n cluster, _ := gocb.Connect(\"couchbase:\/\/localhost\")\r\n bucket, _ = cluster.OpenBucket(\"default\", \"\")\r\n person := Person{FirstName: \"Nic\", LastName: \"Raboy\", SocialNetworking: &amp;SocialNetworking{Twitter: \"nraboy\"}}\r\n createDocument(\"nraboy\", &amp;person)\r\n}\r\n<\/code><\/pre>\n<p>Pruebe este proyecto para ver lo maravillosa que es la API de subdocumentos.<\/p>\n<h2>Conclusi\u00f3n<\/h2>\n<p>Acabas de ver c\u00f3mo usar la API de sub-documentos del servidor Couchbase en una aplicaci\u00f3n GoLang usando el SDK Go de Couchbase. Ya no tendr\u00e1s que preocuparte por<br \/>\npasando alrededor de tus potencialmente enormes documentos NoSQL, arruinando los tiempos de respuesta de tu aplicaci\u00f3n. Si sabes que tus documentos son grandes o s\u00f3lo necesitas<br \/>\npuede hacer uso de esta API.<\/p>\n<p>Para obtener m\u00e1s informaci\u00f3n, visite el sitio web de Couchbase <a href=\"https:\/\/www.couchbase.com\/blog\/es\/developers\/?utm_source=blogs&amp;utm_medium=link&amp;utm_campaign=blogs\">Portal para desarrolladores<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Not too long ago I wrote about working with parts, or fragments, of documents in Couchbase using the Node.js SDK. Being able to work with parts of documents is made possible using Couchbase Server 4.5 and higher and the sub-document [&hellip;]<\/p>\n","protected":false},"author":63,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816,1820],"tags":[1606],"ppma_author":[9032],"class_list":["post-2326","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server","category-golang","tag-sub-document"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Using the Couchbase Sub-Document API with the GoLang SDK - The Couchbase Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/es\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/\" \/>\n<meta property=\"og:locale\" content=\"es_MX\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the Couchbase Sub-Document API with the GoLang SDK\" \/>\n<meta property=\"og:description\" content=\"Not too long ago I wrote about working with parts, or fragments, of documents in Couchbase using the Node.js SDK. Being able to work with parts of documents is made possible using Couchbase Server 4.5 and higher and the sub-document [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/es\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/thepolyglotdeveloper\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-07T15:18:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:09:44+00:00\" \/>\n<meta name=\"author\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nraboy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Using the Couchbase Sub-Document API with the GoLang SDK\",\"datePublished\":\"2016-07-07T15:18:30+00:00\",\"dateModified\":\"2025-06-14T04:09:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/\"},\"wordCount\":889,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"keywords\":[\"sub-document\"],\"articleSection\":[\"Couchbase Server\",\"GoLang\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/\",\"name\":\"Using the Couchbase Sub-Document API with the GoLang SDK - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2016-07-07T15:18:30+00:00\",\"dateModified\":\"2025-06-14T04:09:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-the-couchbase-sub-document-api-with-the-golang-sdk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using the Couchbase Sub-Document API with the GoLang SDK\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/bb545ebe83bb2d12f91095811d0a72e1\",\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g8863514d8bed0cf6080f23db40e00354\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"caption\":\"Nic Raboy, Developer Advocate, Couchbase\"},\"description\":\"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.\",\"sameAs\":[\"https:\\\/\\\/www.thepolyglotdeveloper.com\",\"https:\\\/\\\/www.facebook.com\\\/thepolyglotdeveloper\",\"https:\\\/\\\/x.com\\\/nraboy\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/author\\\/nic-raboy-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Using the Couchbase Sub-Document API with the GoLang SDK - The Couchbase Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/es\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","og_locale":"es_MX","og_type":"article","og_title":"Using the Couchbase Sub-Document API with the GoLang SDK","og_description":"Not too long ago I wrote about working with parts, or fragments, of documents in Couchbase using the Node.js SDK. Being able to work with parts of documents is made possible using Couchbase Server 4.5 and higher and the sub-document [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/es\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2016-07-07T15:18:30+00:00","article_modified_time":"2025-06-14T04:09:44+00:00","author":"Nic Raboy, Developer Advocate, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@nraboy","twitter_misc":{"Written by":"Nic Raboy, Developer Advocate, Couchbase","Est. reading time":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Using the Couchbase Sub-Document API with the GoLang SDK","datePublished":"2016-07-07T15:18:30+00:00","dateModified":"2025-06-14T04:09:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/"},"wordCount":889,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["sub-document"],"articleSection":["Couchbase Server","GoLang"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","url":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","name":"Using the Couchbase Sub-Document API with the GoLang SDK - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2016-07-07T15:18:30+00:00","dateModified":"2025-06-14T04:09:44+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using the Couchbase Sub-Document API with the GoLang SDK"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"El blog de Couchbase","description":"Couchbase, la base de datos NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"El blog de Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1","name":"Nic Raboy, Defensor del Desarrollador, Couchbase","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g8863514d8bed0cf6080f23db40e00354","url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","caption":"Nic Raboy, Developer Advocate, Couchbase"},"description":"Nic Raboy es un defensor de las tecnolog\u00edas modernas de desarrollo web y m\u00f3vil. Tiene experiencia en Java, JavaScript, Golang y una variedad de frameworks como Angular, NativeScript y Apache Cordova. Nic escribe sobre sus experiencias de desarrollo relacionadas con hacer el desarrollo web y m\u00f3vil m\u00e1s f\u00e1cil de entender.","sameAs":["https:\/\/www.thepolyglotdeveloper.com","https:\/\/www.facebook.com\/thepolyglotdeveloper","https:\/\/x.com\/nraboy"],"url":"https:\/\/www.couchbase.com\/blog\/es\/author\/nic-raboy-2\/"}]}},"acf":[],"authors":[{"term_id":9032,"user_id":63,"is_guest":0,"slug":"nic-raboy-2","display_name":"Nic Raboy, Developer Advocate, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/2326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/comments?post=2326"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/2326\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media?parent=2326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/categories?post=2326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/tags?post=2326"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/ppma_author?post=2326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}