{"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\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","title":{"rendered":"Using the Couchbase Sub-Document API with the GoLang SDK"},"content":{"rendered":"<p>Not too long ago I wrote about working with parts, or fragments, of documents in Couchbase<br \/>\n<a href=\"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-nodejs-sdk\/\">using the Node.js SDK<\/a>. Being able to work with<br \/>\nparts of documents is made possible using<br \/>\n<a href=\"https:\/\/developer.couchbase.com\/server\/?utm_source=blogs&amp;utm_medium=link&amp;utm_campaign=blogs\">Couchbase Server<\/a> 4.5 and higher and the sub-document API.<br \/>\nThis is huge because when working with NoSQL documents you may find yourself with very large documents due to all the embedded JSON data. As you probably<br \/>\nknow, making requests on large documents is slow, and in the modern web age, everything needs to be fast. Instead, it is more efficient to only<br \/>\nwork with what you need and not everything all at once.<\/p>\n<p>This time around we&#8217;re going to look at doing the same NoSQL document manipulations we saw in Node.js, but this time with the Go programming language. Let&#8217;s<br \/>\ncome up with a data story for this example. It will be the same data story as the previous example, but let&#8217;s assume we have the following JSON document:<\/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>The above data will be a basic <a href=\"https:\/\/www.couchbase.com\/blog\/user-profile-store-advanced-data-modeling\/\">user profile store<\/a> with social media information. All of our manipulations will be around the social media information, not<br \/>\nthe parent data that surrounds it.<\/p>\n<p>To keep things simple for this guide, we are going to work with a fresh project. At this point we&#8217;ll assume you have both Couchbase Server 4.5+ and<br \/>\nGoLang installed and configured on your machine. If you&#8217;ve not already downloaded the GoLang SDK for Couchbase, execute the following from your Command<br \/>\nPrompt or Terminal:<\/p>\n<pre><code>\r\ngo get github.com\/couchbase\/gocb\r\n<\/code><\/pre>\n<p>Our entire project for this example will reside in a single file. We&#8217;re going to refer to this file as <strong>main.go<\/strong> and it can reside in any<br \/>\nGo project directory you want as long as it meets the requirements of the Go programming language.<\/p>\n<p>To start things off, let&#8217;s create a <code>main<\/code> function inside our project:<\/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>There are a few things to note in the above. First we are establishing a connection to a locally running Couchbase cluster. When the connection has<br \/>\nbeen established we open the <code>default<\/code> bucket. Notice that we are only assigning a value to the <code>bucket<\/code> and not defining it. This<br \/>\nis because we are going to use this variable globally and must define it outside the <code>main<\/code> function. With the bucket open, we are going to<br \/>\ncreate our initial data structure. This data structure <code>Person<\/code> is defined below:<\/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>The <code>Person<\/code> structure will have the basic user information and reference another structure called <code>SocialNetworking<\/code>. Both<br \/>\nstructures are tagged with JSON property names that are to be excluded from print if they are blank.<\/p>\n<p>Going back to the <code>main<\/code> function. Notice that our new person object is missing the website. We&#8217;re going to be adding this later. The first<br \/>\nfunction we call from the <code>main<\/code> function is called <code>createDocument<\/code> and it will add our object to the database. This function<br \/>\nis defined as follows:<\/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>In the above function we are not yet working with fragments of a document. We need to start the example with fresh data first. We&#8217;re going to upsert<br \/>\nthe intitial document and provided there are no errors we&#8217;re going to call <code>getDocument<\/code> to validate it was created and then<br \/>\n<code>getSubDocument<\/code> to get a certain part of the document. The <code>getDocument<\/code> function will be used twice in this application and<br \/>\nit looks like the following:<\/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>In the above <code>getDocument<\/code> function we are getting the entire document based on id, marshalling it into JSON, and then printing it out. This<br \/>\nbrings us to the <code>getSubDocument<\/code> function as seen below:<\/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>In the above <code>getSubDocument<\/code> function we are doing a lookup within a document for a specific property. This is where we start working with<br \/>\nthe sub-document API. The lookup we&#8217;re performing is a lookup for the <code>socialNetworking<\/code> property. Notice that I am referring to the JSON, not<br \/>\nthe <code>struct<\/code> name. When we have the fragment we can marshal it into JSON and then print it out. The result should look like this:<\/p>\n<pre><code>\r\n{\r\n    \"twitter\": \"nraboy\"\r\n}\r\n<\/code><\/pre>\n<p>At the end of the <code>getSubDocument<\/code> function we make a call to a soon to be created <code>upsertSubDocument<\/code> function. This is where<br \/>\nwe are going to modify part of a document without first obtaining the entire document. This function can be seen as follows:<\/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>In the above function we first specify which document we want to manipulate based on the document id. Then we say we want to perform an upsert on a<br \/>\ncertain path or property of document. In this example we are saying we want to upsert a <code>website<\/code> property found in the<br \/>\n<code>socialNetworking<\/code> parent. Note that this entire process happens without actually obtaining the document.<\/p>\n<p>When we&#8217;re done we do a full document lookup again to see what the document looks like as a whole. In case you need this to be put into perspective a<br \/>\nlittle better, the full code to this project can be seen below:<\/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>Take this project for a test drive to see how wonderful the sub-document API is.<\/p>\n<h2>Conclusion<\/h2>\n<p>You just saw how to use the Couchbase Server Sub-Document API in a GoLang application using the Couchbase Go SDK. No longer will you have to worry about<br \/>\npassing around your potentially huge NoSQL documents, ruining your application response times. If you know your documents are large or you only need<br \/>\nbits and pieces, you can make use of this API.<\/p>\n<p>For more information, visit the Couchbase <a href=\"https:\/\/www.couchbase.com\/developers\/?utm_source=blogs&amp;utm_medium=link&amp;utm_campaign=blogs\">Developer Portal<\/a>.<\/p>\n","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"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.2 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\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\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\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\/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 minutes\" \/>\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\":\"en-US\",\"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\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@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\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@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\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354\",\"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\/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\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/","og_locale":"en_US","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\/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 minutes"},"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":"en-US","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":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/using-the-couchbase-sub-document-api-with-the-golang-sdk\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@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":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@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":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354","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\/author\/nic-raboy-2\/"}]}},"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","author_category":"","last_name":"Raboy","first_name":"Nic","job_title":"","user_url":"https:\/\/www.thepolyglotdeveloper.com","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."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=2326"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2326\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=2326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=2326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=2326"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}