{"id":2841,"date":"2017-02-27T07:19:19","date_gmt":"2017-02-27T15:19:19","guid":{"rendered":"http:\/\/www.couchbase.com\/blog\/?p=2841"},"modified":"2020-02-16T18:00:29","modified_gmt":"2020-02-17T02:00:29","slug":"joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/es\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/","title":{"rendered":"Uniendo datos NoSQL: Lenguaje de consulta MongoDB vs Couchbase N1QL"},"content":{"rendered":"<p>One of the most frequent questions I receive when it comes to NoSQL is on the subject of joining data from multiple documents into a single query result. While this question is brought up more frequently from RDBMS developers, I also receive it from NoSQL developers.<\/p>\n<p>When it comes to data joining, every database does it differently, some of which require it to be done through the application layer, rather than the database layer. We&#8217;re going to explore some data joining options between database technologies.<\/p>\n<p><!--more--><\/p>\n<p>In this blog, we&#8217;ll be comparing the process of joining NoSQL documents using the MongoDB $lookup operator versus <a href=\"https:\/\/www.couchbase.com\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase<\/a>&#8216;s more intuitive N1QL query language.<\/p>\n<h2>The Sample Data<\/h2>\n<p>For this example, we&#8217;ll be basing both MongoDB and Couchbase off two sample documents. Assume we&#8217;re working with a classic order and inventory example. For inventory, our documents might look something like this:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \" title=\"Product Documents\">{\r\n    \"id\": \"product-1\",\r\n    \"type\": \"product\",\r\n    \"name\": \"Pokemon Red\",\r\n    \"price\": 29.99\r\n}<\/pre>\n<p>While flat, the above document can properly explain one particular product. It has a unique id which will be involved during the join process. For orders, we might have a document that looks like the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \" title=\"Order Documents\">{\r\n    \"id\": \"order-1\",\r\n    \"type\": \"order\",\r\n    \"products\": [\r\n        {\r\n            \"product_id\": \"product-1\",\r\n            \"quantity\": 2\r\n        }\r\n    ]\r\n}<\/pre>\n<p>The goal here will be to join these two documents in a single query using both MongoDB and Couchbase. However, query language aside, these documents can always be joined via the application layer through multiple queries. This is not the result we&#8217;re after, though.<\/p>\n<h3>Joining Documents with MongoDB and the $lookup Operator<\/h3>\n<p>In recent versions of MongoDB, join queries involve a <code>$lookup<\/code> operator that is part of the aggregation queries. Per the MongoDB <a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/operator\/aggregation\/lookup\/\" target=\"_blank\" rel=\"noopener noreferrer\">documentation<\/a>, this operator performs as the following:<\/p>\n<blockquote><p>Performs a left outer join to an unsharded collection in the same database to filter in documents from the \u201cjoined\u201d collection for processing. The $lookup stage does an equality match between a field from the input documents with a field from the documents of the \u201cjoined\u201d collection.<\/p><\/blockquote>\n<p>To use the <code>$lookup<\/code> operator, you&#8217;d have something like this:<\/p>\n<pre class=\"lang:default highlight:0 decode:true\" title=\"MongoDB Aggregate Query\">db.collection.aggregate([\r\n    {\r\n       $lookup:\r\n         {\r\n           from: &lt;collection to join&gt;,\r\n           localField: &lt;field from the input documents&gt;,\r\n           foreignField: &lt;field from the documents of the \"from\" collection&gt;,\r\n           as: &lt;output array field&gt;\r\n         }\r\n    }\r\n])<\/pre>\n<p>Now this is great, but it doesn&#8217;t work on relationships found in arrays. This means that the <code>$lookup<\/code> operation cannot join the <code>product_id<\/code> found in the <code>products<\/code> array to another document. Instead the array must be &#8220;unwound&#8221; or &#8220;unnested&#8221; first which adds extra complexity to our query:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \" title=\"MongoDB Unwind Then Lookup\">db.orders.aggregate([\r\n    { $unwind: \"$products\" },\r\n    {\r\n        $lookup: {\r\n            from: \"products\",\r\n            localField: \"products.product_id\",\r\n            foreignField: \"_id\",\r\n            as: \"productObjects\"\r\n        }\r\n    }\r\n])<\/pre>\n<p>The <code>$unwind<\/code> operator will flatten the array and then do a join on the now flat objects that were produced. The result of such query would look like this:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">{\r\n    \"_id\" : ObjectId(\"58a3869acbf64c4ace55e713\"),\r\n    \"products\" : {\r\n        \"product_id\" : ObjectId(\"58a3851b2f14a900caa7a731\"),\r\n        \"quantity\" : 2\r\n    },\r\n    \"productObjects\" : [\r\n        {\r\n            \"_id\" : ObjectId(\"58a3851b2f14a900caa7a731\"),\r\n            \"name\" : \"Pokemon Red\",\r\n            \"price\" : 29.99\r\n        }\r\n    ]\r\n}<\/pre>\n<p>Had there been more than one reference in the array, there would have been more results returned. However, what is returned isn&#8217;t very attractive. We still have the old <code>products<\/code> object and now a <code>productsObject<\/code> array. Further manipulations to the data stream needs to happen.<\/p>\n<p>The <code>productsObject<\/code> array should be &#8220;unwound&#8221; and then reconstructed to how we want it. This can be accomplished by doing the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">db.orders.aggregate([\r\n    { $unwind: \"$products\" },\r\n    {\r\n        $lookup: {\r\n            from: \"products\",\r\n            localField: \"products.product_id\",\r\n            foreignField: \"_id\",\r\n            as: \"productObjects\"\r\n        }\r\n    },\r\n    { $unwind: \"$productObjects\"},\r\n    {\r\n        $project: {\r\n            products: {\r\n                \"quantity\": \"$products.quantity\",\r\n                \"name\": \"$productObjects.name\",\r\n                \"price\": \"$productObjects.price\"\r\n            }\r\n        }\r\n    }\r\n])<\/pre>\n<p>Notice that the <code>aggregate<\/code> query is now getting more complex. After doing the join, the result is &#8220;unwound&#8221; and then the result is reconstructed using the <code>$project<\/code> operator.<\/p>\n<p>At this point further manipulations to the result can be made such as grouping the results so that the <code>products<\/code> objects become a single array again. Each manipulation to the data set requires more aggregation code which can easily become messy, complicated, and difficult to read.<\/p>\n<p>This is where Couchbase N1QL becomes so much more pleasant to work with.<\/p>\n<h3>Using Couchbase and N1QL to Join NoSQL Documents<\/h3>\n<p>Let&#8217;s use the same document example that we used for MongoDB. This time we&#8217;re going to write SQL queries with N1QL to get the job done.<\/p>\n<p>The first thing that comes to mind might be to use a <code>JOIN<\/code> in SQL. Our query might look something like this:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SELECT orders.*, product\r\nFROM example AS orders\r\nJOIN example AS product ON KEYS orders.products[*].product_id\r\nWHERE orders.type = 'order'<\/pre>\n<p>In the above example, both the documents exist in the same Couchbase Bucket. A <code>JOIN<\/code> against document ids happens based on the <code>product_id<\/code> values found in the <code>products<\/code> array. The above query would yield results that look like this:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">[\r\n  {\r\n    \"id\": \"order-1\",\r\n    \"product\": {\r\n      \"id\": \"product-1\",\r\n      \"name\": \"Pokemon Red\",\r\n      \"price\": 29.99,\r\n      \"type\": \"product\"\r\n    },\r\n    \"products\": [\r\n      {\r\n        \"product_id\": \"product-1\",\r\n        \"quantity\": 2\r\n      }\r\n    ],\r\n    \"type\": \"order\"\r\n  }\r\n]<\/pre>\n<p>Like with MongoDB, there will be a result for every item of the <code>products<\/code> array that matches. In fairness, while the N1QL version was easier to write, it wasn&#8217;t necessarily any more difficult than the MongoDB Query Language at this point. As we manipulate the data more, Couchbase becomes a lot easier by comparison.<\/p>\n<p>For example, let&#8217;s say we wanted to clean up the results:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SELECT orders.id, orders.type, OBJECT_PUT(product, \"quantity\", products.quantity) AS product\r\nFROM example AS orders\r\nUNNEST orders.products AS products\r\nJOIN example AS product ON KEYS products.product_id\r\nWHERE orders.type = 'order'<\/pre>\n<p>There are some major differences in what we&#8217;re doing in the above, but minor differences in how we&#8217;re doing them. Instead of joining directly on the array, we are first flattening or &#8220;unnesting&#8221; the array, like what we saw in the MongoDB <code>$unwind<\/code> operator. The join is now happening on each of the flattened results. Finally, the <code>quantity<\/code> from the original object is added to the new object.<\/p>\n<p>The result to the above query would look something like this:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">[\r\n  {\r\n    \"id\": \"order-1\",\r\n    \"product\": {\r\n      \"id\": \"product-1\",\r\n      \"name\": \"Pokemon Red\",\r\n      \"price\": 29.99,\r\n      \"quantity\": 2,\r\n      \"type\": \"product\"\r\n    },\r\n    \"type\": \"order\"\r\n  }\r\n]<\/pre>\n<p>Let&#8217;s say that the original <code>products<\/code> array had more than one product reference in it. Instead of returning several objects based on the <code>JOIN<\/code> criteria we saw above, it might make sense to re-pack that original array.<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">SELECT orders.id, orders.type, ARRAY_AGG(OBJECT_PUT(product, \"quantity\", products.quantity)) AS products\r\nFROM example AS orders\r\nUNNEST orders.products AS products\r\nJOIN example AS product ON KEYS products.product_id\r\nWHERE orders.type = 'order'\r\nGROUP BY orders<\/pre>\n<p>In the above query we&#8217;ve only added <code>ARRAY_AGG<\/code> and a <code>GROUP BY<\/code>, but as a result, each joined document shows up in the <code>products<\/code> array instead of the id value.<\/p>\n<p>Don&#8217;t want to use an actual <code>JOIN<\/code> operator? Try using a SQL subquery instead.<\/p>\n<h2>Conclusion<\/h2>\n<p>In NoSQL, joining data is a very popular concern for developers that are seasoned RDBMS veterans. Because MongoDB is a very popular NoSQL technology, I thought it would be good to use for comparing to how Couchbase handles document joining. For light operations, <code>$lookup<\/code> operator is tolerable, but as join queries in MongoDB become more complex, you may need to take a step back. With N1QL, writing complex queries that include joining operations becomes very easy and stays easy regardless of how complex the query is.<\/p>\n<p>For more information on N1QL and Couchbase, visit the <a href=\"https:\/\/developer.couchbase.com\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase Developer Portal<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most frequent questions I receive when it comes to NoSQL is on the subject of joining data from multiple documents into a single query result. While this question is brought up more frequently from RDBMS developers, I [&hellip;]<\/p>\n","protected":false},"author":63,"featured_media":2787,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1816,1812],"tags":[1309,1861],"ppma_author":[9032],"class_list":["post-2841","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-server","category-n1ql-query","tag-mongodb","tag-unnest"],"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>Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL<\/title>\n<meta name=\"description\" content=\"Learn the secrets of joining NoSQL documents in this tutorial featuring the MongoDB Query Language and Couchbase&#039;s intuitive N1QL query language.\" \/>\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\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/\" \/>\n<meta property=\"og:locale\" content=\"es_MX\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL\" \/>\n<meta property=\"og:description\" content=\"Learn the secrets of joining NoSQL documents in this tutorial featuring the MongoDB Query Language and Couchbase&#039;s intuitive N1QL query language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/es\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/\" \/>\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=\"2017-02-27T15:19:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-02-17T02:00:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/02\/mongo-to-couchbase.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"389\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"6 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL\",\"datePublished\":\"2017-02-27T15:19:19+00:00\",\"dateModified\":\"2020-02-17T02:00:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/\"},\"wordCount\":975,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2017\\\/02\\\/mongo-to-couchbase.png\",\"keywords\":[\"mongodb\",\"unnest\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Server\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/\",\"name\":\"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2017\\\/02\\\/mongo-to-couchbase.png\",\"datePublished\":\"2017-02-27T15:19:19+00:00\",\"dateModified\":\"2020-02-17T02:00:29+00:00\",\"description\":\"Learn the secrets of joining NoSQL documents in this tutorial featuring the MongoDB Query Language and Couchbase's intuitive N1QL query language.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2017\\\/02\\\/mongo-to-couchbase.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2017\\\/02\\\/mongo-to-couchbase.png\",\"width\":1100,\"height\":389},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL\"}]},{\"@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":"Uniendo datos NoSQL: Lenguaje de consulta MongoDB vs Couchbase N1QL","description":"Learn the secrets of joining NoSQL documents in this tutorial featuring the MongoDB Query Language and Couchbase's intuitive N1QL query language.","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\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/","og_locale":"es_MX","og_type":"article","og_title":"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL","og_description":"Learn the secrets of joining NoSQL documents in this tutorial featuring the MongoDB Query Language and Couchbase's intuitive N1QL query language.","og_url":"https:\/\/www.couchbase.com\/blog\/es\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2017-02-27T15:19:19+00:00","article_modified_time":"2020-02-17T02:00:29+00:00","og_image":[{"width":1100,"height":389,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/02\/mongo-to-couchbase.png","type":"image\/png"}],"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":"6 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL","datePublished":"2017-02-27T15:19:19+00:00","dateModified":"2020-02-17T02:00:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/"},"wordCount":975,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/02\/mongo-to-couchbase.png","keywords":["mongodb","unnest"],"articleSection":["Best Practices and Tutorials","Couchbase Server","SQL++ \/ N1QL Query"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/","url":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/","name":"Uniendo datos NoSQL: Lenguaje de consulta MongoDB vs Couchbase N1QL","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/02\/mongo-to-couchbase.png","datePublished":"2017-02-27T15:19:19+00:00","dateModified":"2020-02-17T02:00:29+00:00","description":"Learn the secrets of joining NoSQL documents in this tutorial featuring the MongoDB Query Language and Couchbase's intuitive N1QL query language.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/02\/mongo-to-couchbase.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/02\/mongo-to-couchbase.png","width":1100,"height":389},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/joining-nosql-documents-mongodb-query-language-vs-couchbase-n1ql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Joining NoSQL Data: MongoDB Query Language vs Couchbase N1QL"}]},{"@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\/2841","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=2841"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/2841\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media\/2787"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media?parent=2841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/categories?post=2841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/tags?post=2841"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/ppma_author?post=2841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}