{"id":7255,"date":"2019-08-09T10:00:42","date_gmt":"2019-08-09T17:00:42","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=7255"},"modified":"2023-05-25T04:26:23","modified_gmt":"2023-05-25T11:26:23","slug":"get-started-with-couchbase-collections-using-the-demo-app","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/","title":{"rendered":"Get Started with Couchbase Collections Using the Demo App"},"content":{"rendered":"<p>Collections are a new feature in Couchbase 6.5. They let you group similar documents within each bucket, just as tables in relational databases collect similar records within each database. Collections will be fully supported in Couchbase 7.0, but you can try them right now in the Couchbase 6.5 release as a Developer Preview feature. The Demo Application already uses them.<\/p>\n<p><strong>What Are Collections?<\/strong><br \/>\nIf you are coming from the world of relational databases, you can think of collections as tables. All the documents within a couchbase collection should be of the same type, just as all the records in a relational table are of the same type. There might be a &#8220;customer&#8221; table or a &#8220;product&#8221; table in a relational schema; similarly, there might be a &#8220;customer&#8221; collection in a Couchbase bucket.<\/p>\n<p>In older versions of Couchbase, data was organized like this:<\/p>\n<ul>\n<li>Cluster\n<ul>\n<li>Bucket\n<ul>\n<li>Document<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>In Couchbase 6.5, there are two more layers, like this:<\/p>\n<ul>\n<li>Cluster\n<ul>\n<li>Bucket\n<ul>\n<li><strong>Scope<\/strong>\n<ul>\n<li><strong>Collection<\/strong>\n<ul>\n<li>Document<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><b>How Are Collections Useful?<\/b><\/p>\n<p>Collections are the lowest level of document organization, and directly contain documents. They are useful because they let you group documents more precisely than was possible before. Rather than dumping all different types of documents (products, orders, customers) into a single bucket and distinguishing them by a type field, you can instead create a collection for each type. And when you query, you can query against the collection, not just the whole bucket. You will also eventually be able to control access at the collection level.<\/p>\n<p>Scopes are the level of organization above collections. Scopes contain collections and collections contain documents. There are different ways to use scopes, depending on what the Couchbase cluster is being used for. If it is supporting many different internal applications for a company, each application should have a scope of its own. If the cluster is being used to serve many client organizations, each running its own copy of an application, each copy should have a scope of its own. Similarly, if a cluster is being used by dev groups, perhaps for testing, the unit of allocation should be a scope. In each case, the owner can then create whatever collections they want under the scope they are assigned.<\/p>\n<p>Scopes have to be unique within their buckets, and collections have to be unique within their scopes. Accordingly, the &#8220;default&#8221; bucket could contain two scopes &#8220;dev&#8221; and &#8220;prod&#8221;, each with their own &#8220;products&#8221; and &#8220;customers&#8221; collections.<\/p>\n<p><b>Use of Collections<\/b><\/p>\n<p>You can see collections and scopes being used in the latest version of the Couchbase Demo Application, here:<\/p>\n<p><a href=\"https:\/\/github.com\/couchbaselabs\/try-cb-java\/tree\/6.5.0-branch\">https:\/\/github.com\/couchbaselabs\/try-cb-java\/tree\/6.5.0-branch<\/a><\/p>\n<p>This application uses an existing &#8220;travel-sample&#8221; bucket as is to let the user search for flights and hotels, but stores its own user and bookings data in collections. The structure being used is this:<\/p>\n<ul>\n<li style=\"font-weight: 400\">Bucket: default\n<ul>\n<li style=\"font-weight: 400\">Scope: larson-travel\n<ul>\n<li style=\"font-weight: 400\">Collection: users<\/li>\n<li style=\"font-weight: 400\">Collection: flights<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>When the user creates an account, a document is created in the &#8220;users&#8221; collection. When they book flights, documents are created in the &#8220;flights&#8221; collection, and referenced in the user&#8217;s document in the &#8220;users&#8221; collection.<\/p>\n<p>This design allows multiple applications to share the same bucket. If we had a second instance of the demo app, used by another travel agency, we could just create another scope (with its own &#8220;users&#8221; and &#8220;flights&#8221; collections,) and point the second instance at this scope by updating its application.properties file. The two instances would operate side by side, without interfering with each other.<\/p>\n<p><b>Example Code<\/b><\/p>\n<p>To begin with, the bucket and scope that contain user and bookings information are named in the application.properties file:<\/p>\n<pre class=\"nums:false lang:default decode:true\">storage.clientorg.bucket=default\r\nstorage.clientorg.scope=larson-travel<\/pre>\n<p>These configuration values are picked up in the Database.java file:<\/p>\n<pre class=\"nums:false lang:java decode:true \">@Configuration\r\npublic class Database {\r\n\r\n    ...\r\n\r\n    @Value(\"${storage.clientorg.bucket}\")\r\n    private String clientOrgBucket;\r\n\r\n    @Value(\"${storage.clientorg.scope}\")\r\n    private String clientOrgScope;\r\n\r\n    ...\r\n\r\n    public Bucket clientOrgBucket() {\r\n        return loginCluster().bucket(clientOrgBucket);\r\n    }\r\n\r\n    public @Bean Scope clientOrgScope() {\r\n        return clientOrgBucket().scope(clientOrgScope);\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>In User.java, we see how a new flight is registered for the user. The scope bean, created above, is passed in. The username is the id the name the user logged in with.<\/p>\n<pre class=\"nums:false lang:java decode:true java\">    public Result&lt;Map&lt;String, Object&gt;&gt; registerFlightForUser(final Scope scope, \r\n        final String username, final JsonArray newFlights) {\r\n<\/pre>\n<p>The id of the user document is the username of the user. The application knows to get it from the &#8220;users&#8221; collection, in the collection used by the application.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        String userId = username;\r\n        Collection usersCollection = scope.collection(USERS_COLLECTION_NAME);\r\n        Collection flightsCollection = scope.collection(FLIGHTS_COLLECTION_NAME);\r\n        Optional&lt;GetResult&gt; userDataFetch = usersCollection.get(userId);\r\n        if (!userDataFetch.isPresent()) {\r\n            throw new IllegalStateException();\r\n        }\r\n        JsonObject userData = userDataFetch.get().contentAsObject();\r\n\r\n        if (newFlights == null) {\r\n            throw new IllegalArgumentException(\"No flights in payload\");\r\n        }\r\n\r\n        JsonArray added = JsonArray.empty();\r\n<\/pre>\n<p>The flights the user has booked are stored in the user document, in an array named &#8220;flights&#8221;.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        JsonArray allBookedFlights = userData.getArray(\"flights\");\r\n        if(allBookedFlights == null) {\r\n            allBookedFlights = JsonArray.create();\r\n        }\r\n<\/pre>\n<p>We add the new flights to the existing flights.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        for (Object newFlight : newFlights) {\r\n            checkFlight(newFlight);\r\n            JsonObject t = ((JsonObject) newFlight);\r\n            t.put(\"bookedon\", \"try-cb-java\");\r\n            String flightId = UUID.randomUUID().toString();\r\n            flightsCollection.insert(flightId, t);\r\n            allBookedFlights.add(flightId);\r\n            added.add(t);\r\n        }\r\n\r\n        userData.put(\"flights\", allBookedFlights);\r\n<\/pre>\n<p>Then we store the new version of the user document.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        usersCollection.upsert(userId, userData);\r\n\r\n        JsonObject responseData = JsonObject.create()\r\n            .put(\"added\", added);\r\n\r\n        return Result.of(responseData.toMap(), \r\n            \"Booked flight in Couchbase document \" + userId);\r\n    }\r\n<\/pre>\n<p>Just below, we see how the flights of a user are retrieved.<\/p>\n<pre class=\"nums:false lang:java decode:true\">    public List&lt;Map&lt;String, Object&gt;&gt; getFlightsForUser(final Scope scope, \r\n        final String username) {\r\n<\/pre>\n<p>Get the user document from the &#8220;users&#8221; collection.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        Collection users = scope.collection(USERS_COLLECTION_NAME);\r\n        Optional&lt;GetResult&gt; doc = users.get(username);\r\n        if (!doc.isPresent()) {\r\n            return Collections.emptyList();\r\n        }\r\n        JsonObject data = doc.get().contentAsObject();\r\n<\/pre>\n<p>Get the &#8220;flights&#8221; array from the user document. It contains a list of flight ids.<\/p>\n<pre class=\"nums:false lang:default decode:true \">        JsonArray flights = data.getArray(\"flights\");\r\n        if (flights == null) {\r\n            return Collections.emptyList();\r\n        }\r\n<\/pre>\n<p>Retrieve each flight document from the &#8220;flights&#8221; collection&#8221; by ID.<\/p>\n<pre class=\"nums:false lang:java decode:true \">        \/\/ The \"flights\" array contains flight ids. Convert them to actual objects.\r\n        Collection flightsCollection = scope.collection(FLIGHTS_COLLECTION_NAME);\r\n        List&lt;Map&lt;String, Object&gt;&gt; results = new ArrayList&lt;Map&lt;String, Object&gt;&gt;();\r\n        for (int i = 0; i &lt; flights.size(); i++) {\r\n            String flightId = flights.getString(i);\r\n            Optional&lt;GetResult&gt; res = flightsCollection.get(flightId);\r\n            if (!res.isPresent()) {\r\n                throw new RuntimeException(\"Unable to retrieve flight id \" + flightId);\r\n            }\r\n            Map&lt;String, Object&gt; flight = res.get().contentAsObject().toMap();\r\n            results.add(flight);\r\n        }\r\n        return results;\r\n    }\r\n<\/pre>\n<p><b>Changes From Earlier Code<\/b><\/p>\n<p>The code for working with users and their flights was quite different in the previous version, which didn&#8217;t use collections. There, booked flights were stored directly in the user document. The user document was stored directly in the &#8220;travel-sample&#8221; table. Here is the original code for the registerFlightForUser() function.<\/p>\n<pre class=\"nums:false lang:java decode:true\">   public Result&lt;Map&lt;String, Object&gt;&gt; registerFlightForUser(final Bucket bucket,\r\n \tfinal String username, final JsonArray newFlights) {\r\n<\/pre>\n<p>Notice the use of a prefix to mark the type of document. This isn&#8217;t necessary once collections are available.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        JsonDocument userData = bucket.get(\"user::\" + username);\r\n        if (userData == null) {\r\n            throw new IllegalStateException();\r\n        }\r\n\r\n        if (newFlights == null) {\r\n            throw new IllegalArgumentException(\"No flights in payload\");\r\n        }\r\n\r\n        JsonArray added = JsonArray.empty();\r\n<\/pre>\n<p>We retrieve the array of flights, which is already in the document.<\/p>\n<pre class=\"nums:false lang:java decode:true\">        JsonArray allBookedFlights = userData.content().getArray(\"flights\");\r\n        if(allBookedFlights == null) {\r\n            allBookedFlights = JsonArray.create();\r\n        }\r\n\r\n        for (Object newFlight : newFlights) {\r\n            checkFlight(newFlight);\r\n            JsonObject t = ((JsonObject) newFlight);\r\n            t.put(\"bookedon\", \"try-cb-java\");\r\n<\/pre>\n<p>We add the flights to the array of booked flights.<\/p>\n<pre class=\"nums:false lang:java decode:true\">            allBookedFlights.add(t);\r\n            added.add(t);\r\n        }\r\n\r\n        userData.content().put(\"flights\", allBookedFlights);\r\n<\/pre>\n<p>And we store the user document.<\/p>\n<pre class=\"nums:false lang:java decode:true \">        JsonDocument response = bucket.upsert(userData);\r\n\r\n        JsonObject responseData = JsonObject.create()\r\n            .put(\"added\", added);\r\n\r\n        return Result.of(responseData.toMap(), \"Booked flight in Couchbase document \" + response.id());\r\n    }\r\n<\/pre>\n<p>Obviously, separating the booked flights from the user isn&#8217;t terribly compelling in a toy application. But in a production application, where we are storing many types of information of information about each user, it would make sense to store some records outside the user document, particularly any that were large or numerous or prone to changing frequently.<\/p>\n<p><b>Scopes and Collections Documentation<\/b><\/p>\n<p>To find out more about how to work with scopes and collection directly, consult <a href=\"https:\/\/docs.couchbase.com\/server\/6.5\/developer-preview\/collections\/collections-overview.html\">this documentation<\/a>, which explains the RESTful API for working with both, the relevant CLI commands, and information about collections available from <em>cbstats<\/em>.<\/p>\n<p><b>Summary<\/b><\/p>\n<p>Collections and scopes let you organize documents within a Couchbase bucket, just as tables and schemas let you organized rows within relational databases. The current Couchbase 6.5 GA release provides early, limited support for collections and scopes as a Developer Preview feature. To get started with collections and scopes, you can start working with the Java Demo Application right now.<\/p>\n<h3>Resources<\/h3>\n<p class=\"p1\"><i>Download<\/i><\/p>\n<p class=\"p2\"><span class=\"s1\"><a href=\"https:\/\/couchbase.com\/downloads?family=server&amp;product=couchbase-server-developer\">Download Couchbase Server 6.5<\/a><\/span><\/p>\n<p class=\"p1\"><i>\u00a0<\/i><i>Documentation<\/i><\/p>\n<p><a href=\"https:\/\/docs.couchbase.com\/server\/6.5\/developer-preview\/collections\/collections-overview.html\">Couchbase Collections 6.5 Documentation<\/a><\/p>\n<p class=\"p2\"><span class=\"s1\"><a href=\"https:\/\/docs.couchbase.com\/server\/6.5\/release-notes\/relnotes.html\">Couchbase Server 6.5 Release Notes<\/a><\/span><\/p>\n<p class=\"p2\"><span class=\"s1\"><a href=\"https:\/\/docs.couchbase.com\/server\/6.5\/introduction\/whats-new.html\">Couchbase Server 6.5 What\u2019s New<\/a><\/span><\/p>\n<p class=\"p1\"><i>Blogs<\/i><\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/introducing-collections-developer-preview-in-couchbase-server-6-5\/\">Introducing Collections &#8211; Developer Preview in Couchbase Server 6.5<\/a><\/p>\n<p class=\"p2\"><span class=\"s1\"><a href=\"https:\/\/www.couchbase.com\/blog\/announcing-couchbase-server-6-5-0-whats-new-and-improved\/\">Announcing Couchbase Server 6.5 \u2013 What\u2019s New and Improved<\/a><\/span><\/p>\n<p class=\"p2\"><span class=\"s1\"><a href=\"https:\/\/www.couchbase.com\/blog\/tag\/6-5\/\"><b>All 6.5 Blogs<\/b><\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Collections are a new feature in Couchbase 6.5. They let you group similar documents within each bucket, just as tables in relational databases collect similar records within each database. Collections will be fully supported in Couchbase 7.0, but you can [&hellip;]<\/p>\n","protected":false},"author":8157,"featured_media":7449,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1816,1819],"tags":[2378,2364],"ppma_author":[9058],"class_list":["post-7255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-server","category-data-modeling","tag-6-5","tag-collections"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get Started with Couchbase Collections Using the Demo App<\/title>\n<meta name=\"description\" content=\"Collections let you group similar documents within each bucket, just like records in tables. Collections previewed in Couchbase 6.5.\" \/>\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\/get-started-with-couchbase-collections-using-the-demo-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Started with Couchbase Collections Using the Demo App\" \/>\n<meta property=\"og:description\" content=\"Collections let you group similar documents within each bucket, just like records in tables. Collections previewed in Couchbase 6.5.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-09T17:00:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-25T11:26:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/08\/Transactions-alternative-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1400\" \/>\n\t<meta property=\"og:image:height\" content=\"553\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Johan Larson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Johan Larson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/\"},\"author\":{\"name\":\"Johan Larson\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/043ccbbfc54b95927c73f81ec7f6a0a1\"},\"headline\":\"Get Started with Couchbase Collections Using the Demo App\",\"datePublished\":\"2019-08-09T17:00:42+00:00\",\"dateModified\":\"2023-05-25T11:26:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/\"},\"wordCount\":1055,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg\",\"keywords\":[\"6.5\",\"collections\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Server\",\"Data Modeling\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/\",\"name\":\"Get Started with Couchbase Collections Using the Demo App\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg\",\"datePublished\":\"2019-08-09T17:00:42+00:00\",\"dateModified\":\"2023-05-25T11:26:23+00:00\",\"description\":\"Collections let you group similar documents within each bucket, just like records in tables. Collections previewed in Couchbase 6.5.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg\",\"width\":1400,\"height\":553},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Started with Couchbase Collections Using the Demo App\"}]},{\"@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\/043ccbbfc54b95927c73f81ec7f6a0a1\",\"name\":\"Johan Larson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/93b175bb8728e12439dd573fc27b9d1a\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2ddf616344da1f84e85c42ba2bfc102e28380128c107cc21eeecc26edc737227?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2ddf616344da1f84e85c42ba2bfc102e28380128c107cc21eeecc26edc737227?s=96&d=mm&r=g\",\"caption\":\"Johan Larson\"},\"description\":\"Johan Larson is a Senior Software Engineer at Couchbase. Johan's work responsibility is building an SQL-based query language for JSON data in a distributed NoSQL system.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/johan-larson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Get Started with Couchbase Collections Using the Demo App","description":"Collections let you group similar documents within each bucket, just like records in tables. Collections previewed in Couchbase 6.5.","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\/get-started-with-couchbase-collections-using-the-demo-app\/","og_locale":"en_US","og_type":"article","og_title":"Get Started with Couchbase Collections Using the Demo App","og_description":"Collections let you group similar documents within each bucket, just like records in tables. Collections previewed in Couchbase 6.5.","og_url":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/","og_site_name":"The Couchbase Blog","article_published_time":"2019-08-09T17:00:42+00:00","article_modified_time":"2023-05-25T11:26:23+00:00","og_image":[{"width":1400,"height":553,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/08\/Transactions-alternative-1.jpg","type":"image\/jpeg"}],"author":"Johan Larson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Johan Larson","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/"},"author":{"name":"Johan Larson","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/043ccbbfc54b95927c73f81ec7f6a0a1"},"headline":"Get Started with Couchbase Collections Using the Demo App","datePublished":"2019-08-09T17:00:42+00:00","dateModified":"2023-05-25T11:26:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/"},"wordCount":1055,"commentCount":3,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg","keywords":["6.5","collections"],"articleSection":["Best Practices and Tutorials","Couchbase Server","Data Modeling"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/","url":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/","name":"Get Started with Couchbase Collections Using the Demo App","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg","datePublished":"2019-08-09T17:00:42+00:00","dateModified":"2023-05-25T11:26:23+00:00","description":"Collections let you group similar documents within each bucket, just like records in tables. Collections previewed in Couchbase 6.5.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-1.jpg","width":1400,"height":553},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/get-started-with-couchbase-collections-using-the-demo-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Get Started with Couchbase Collections Using the Demo App"}]},{"@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\/043ccbbfc54b95927c73f81ec7f6a0a1","name":"Johan Larson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/93b175bb8728e12439dd573fc27b9d1a","url":"https:\/\/secure.gravatar.com\/avatar\/2ddf616344da1f84e85c42ba2bfc102e28380128c107cc21eeecc26edc737227?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2ddf616344da1f84e85c42ba2bfc102e28380128c107cc21eeecc26edc737227?s=96&d=mm&r=g","caption":"Johan Larson"},"description":"Johan Larson is a Senior Software Engineer at Couchbase. Johan's work responsibility is building an SQL-based query language for JSON data in a distributed NoSQL system.","url":"https:\/\/www.couchbase.com\/blog\/author\/johan-larson\/"}]}},"authors":[{"term_id":9058,"user_id":8157,"is_guest":0,"slug":"johan-larson","display_name":"Johan Larson","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/2ddf616344da1f84e85c42ba2bfc102e28380128c107cc21eeecc26edc737227?s=96&d=mm&r=g","author_category":"","last_name":"Larson","first_name":"Johan","job_title":"","user_url":"","description":"Johan Larson is a Senior Software Engineer at Couchbase. Johan's work responsibility is building an SQL-based query language for JSON data in a distributed NoSQL system."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/7255","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\/8157"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=7255"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/7255\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/7449"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=7255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=7255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=7255"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=7255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}