{"id":1725,"date":"2014-12-16T18:55:07","date_gmt":"2014-12-16T18:55:07","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=1725"},"modified":"2014-12-16T18:55:07","modified_gmt":"2014-12-16T18:55:07","slug":"nodejs-and-n1ql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/","title":{"rendered":"Node.js and N1QL"},"content":{"rendered":"<p>So, recently I added support to our Node.js client for executing N1QL queries against your cluster, providing you are running an instance of the N1QL engine (to get a hold of the updated version of the Node.js client with this support, point npm to our github master branch at https:\/\/github.com\/couchbase\/couchnode). \u00a0When I implemented it, I didn\u2019t have very much to test against at the time, so I figured it would be a interesting endeavorer to see how nice the Node.js\u2019s beer-sample example would look if we used entirely N1QL queries rather than using any views.<\/p>\n<p>I first started by converting over the basic queries which simply selected all beers or breweries from the sample data, and then moved on to converting the live-search querying to use N1QL as well. \u00a0I figured I would write a little blog post on the conversions and make some remarks about what I noticed along the way.<\/p>\n<p>Here is our first query:<\/p>\n<div class=\"geshifilter\">\n<div class=\"javascript geshifilter-javascript\" style=\"font-family:monospace;\"><span style=\"color: #003366; font-weight: bold;\">var<\/span> q <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 limit <span style=\"color: #339933;\">:<\/span> ENTRIES_PER_PAGE<span style=\"color: #339933;\">,<\/span><br \/>\u00a0 stale <span style=\"color: #339933;\">:<\/span> <span style=\"color: #003366; font-weight: bold;\">false<\/span><br \/><span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span><br \/>db.<span style=\"color: #660066;\">view<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #3366CC;\">&#8220;beer&#8221;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366CC;\">&#8220;by_name&#8221;<\/span><span style=\"color: #339933;\">,<\/span> q<span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">query<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> values<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 <span style=\"color: #003366; font-weight: bold;\">var<\/span> keys <span style=\"color: #339933;\">=<\/span> _.<span style=\"color: #660066;\">pluck<\/span><span style=\"color: #009900;\">(<\/span>values<span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366CC;\">&#8216;id&#8217;<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 db.<span style=\"color: #660066;\">getMulti<\/span><span style=\"color: #009900;\">(<\/span> keys<span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> results<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">var<\/span> beers <span style=\"color: #339933;\">=<\/span> _.<span style=\"color: #660066;\">map<\/span><span style=\"color: #009900;\">(<\/span>results<span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>v<span style=\"color: #339933;\">,<\/span> k<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 v.<span style=\"color: #660066;\">value<\/span>.<span style=\"color: #660066;\">id<\/span> <span style=\"color: #339933;\">=<\/span> k<span style=\"color: #339933;\">;<\/span><br \/>\u00a0 \u00a0 \u00a0 <span style=\"color: #000066; font-weight: bold;\">return<\/span> v.<span style=\"color: #660066;\">value<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 \u00a0 res.<span style=\"color: #660066;\">render<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8216;beer\/index&#8217;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #3366CC;\">&#8216;beers&#8217;<\/span><span style=\"color: #339933;\">:<\/span>beers<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><br \/><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/div>\n<\/div>\n<p>and the converted version:<\/p>\n<div class=\"geshifilter\">\n<div class=\"javascript geshifilter-javascript\" style=\"font-family:monospace;\">db.<span style=\"color: #660066;\">query<\/span><span style=\"color: #009900;\">(<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #3366CC;\">&#8220;SELECT META().id AS id, * FROM beer-sample WHERE type=&#8217;beer&#8217; LIMIT &#8220;<\/span> <span style=\"color: #339933;\">+<\/span> ENTRIES_PER_PAGE<span style=\"color: #339933;\">,<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> beers<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 res.<span style=\"color: #660066;\">render<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8216;beer\/index&#8217;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #3366CC;\">&#8216;beers&#8217;<\/span><span style=\"color: #339933;\">:<\/span>beers<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/div>\n<\/div>\n<p>As you can see, we no longer need to do two separate operations to retrieve the list. \u00a0We can execute our N1QL query which will returns all the information that we need, and formats it appropriately; rather than needing to reformat the data and add our id values, we can simply select it as part of the result set. \u00a0I find the N1QL version here is much more concise and appreciate how simple it was to construct the query.<\/p>\n<p>I then converted the brewery listing function following a similar path, and here is what I ended up with, as you can see, it is similarly beautiful and concise:<\/p>\n<div class=\"geshifilter\">\n<div class=\"javascript geshifilter-javascript\" style=\"font-family:monospace;\">db.<span style=\"color: #660066;\">query<\/span><span style=\"color: #009900;\">(<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #3366CC;\">&#8220;SELECT META().id AS id, name FROM beer-sample WHERE type=&#8217;brewery&#8217; LIMIT &#8220;<\/span> <span style=\"color: #339933;\">+<\/span> ENTRIES_PER_PAGE<span style=\"color: #339933;\">,<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> breweries<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 res.<span style=\"color: #660066;\">render<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8216;brewery\/index&#8217;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #3366CC;\">&#8216;breweries&#8217;<\/span><span style=\"color: #339933;\">:<\/span>breweries<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/div>\n<\/div>\n<p><span style=\"font-family: inherit; font-size: 1em; line-height: 1.4375em;\">Next I converted the searching methods. \u00a0These were a bit more of a challenge as looking at the original code directly, without thinking about what it was trying to achieve, the semantics were not immediately obvious, here is a look at what it looked like:<\/span><\/p>\n<div class=\"geshifilter\">\n<div class=\"javascript geshifilter-javascript\" style=\"font-family:monospace;\"><span style=\"color: #003366; font-weight: bold;\">var<\/span> q <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">{<\/span> startkey <span style=\"color: #339933;\">:<\/span> value<span style=\"color: #339933;\">,<\/span><br \/>\u00a0 endkey <span style=\"color: #339933;\">:<\/span> value <span style=\"color: #339933;\">+<\/span> JSON.<span style=\"color: #660066;\">parse<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8216;&#8221;<span style=\"color: #000099; font-weight: bold;\">u<\/span>0FFF&#8221;&#8216;<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span><br \/>\u00a0 stale <span style=\"color: #339933;\">:<\/span> <span style=\"color: #003366; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">,<\/span><br \/>\u00a0 limit <span style=\"color: #339933;\">:<\/span> ENTRIES_PER_PAGE <span style=\"color: #009900;\">}<\/span><br \/>db.<span style=\"color: #660066;\">view<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #3366CC;\">&#8220;beer&#8221;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366CC;\">&#8220;by_name&#8221;<\/span><span style=\"color: #339933;\">,<\/span> q<span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">query<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> values<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 <span style=\"color: #003366; font-weight: bold;\">var<\/span> keys <span style=\"color: #339933;\">=<\/span> _.<span style=\"color: #660066;\">pluck<\/span><span style=\"color: #009900;\">(<\/span>values<span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366CC;\">&#8216;id&#8217;<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 db.<span style=\"color: #660066;\">getMulti<\/span><span style=\"color: #009900;\">(<\/span> keys<span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> results<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">var<\/span> beers <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">[<\/span><span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #000066; font-weight: bold;\">for<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">var<\/span> k <span style=\"color: #000066; font-weight: bold;\">in<\/span> results<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 beers.<span style=\"color: #660066;\">push<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #3366CC;\">&#8216;id&#8217;<\/span><span style=\"color: #339933;\">:<\/span> k<span style=\"color: #339933;\">,<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #3366CC;\">&#8216;name&#8217;<\/span><span style=\"color: #339933;\">:<\/span> results<span style=\"color: #009900;\">[<\/span>k<span style=\"color: #009900;\">]<\/span>.<span style=\"color: #660066;\">value<\/span>.<span style=\"color: #000066;\">name<\/span><span style=\"color: #339933;\">,<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #3366CC;\">&#8216;brewery_id&#8217;<\/span><span style=\"color: #339933;\">:<\/span> results<span style=\"color: #009900;\">[<\/span>k<span style=\"color: #009900;\">]<\/span>.<span style=\"color: #660066;\">value<\/span>.<span style=\"color: #660066;\">brewery_id<\/span><br \/>\u00a0 \u00a0 \u00a0 <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #009900;\">}<\/span><br \/>\u00a0 \u00a0 res.<span style=\"color: #660066;\">send<\/span><span style=\"color: #009900;\">(<\/span>beers<span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/>\u00a0 <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/div>\n<\/div>\n<p>Again, we have quite a bit of code to achieve something which you should expect to be quite simple. \u00a0In case you can\u2019t tell, the map\/reduce query above retrieves a listing of beers whose names begin with the value entered by the user. \u00a0We are going to convert this to a N1QL LIKE clause, and as an added bonus, we will allow the search term to appear anywhere in the string, instead of requiring it at the beginning:<\/p>\n<div class=\"geshifilter\">\n<div class=\"javascript geshifilter-javascript\" style=\"font-family:monospace;\">db.<span style=\"color: #660066;\">query<\/span><span style=\"color: #009900;\">(<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #3366CC;\">&#8220;SELECT META().id, name, brewery_id FROM beer-sample WHERE type=&#8217;beer&#8217; AND LOWER(name) LIKE &#8216;%&#8221;<\/span> <span style=\"color: #339933;\">+<\/span> term <span style=\"color: #339933;\">+<\/span> <span style=\"color: #3366CC;\">&#8220;%&#8217; LIMIT &#8220;<\/span> <span style=\"color: #339933;\">+<\/span> ENTRIES_PER_PAGE<span style=\"color: #339933;\">,<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>err<span style=\"color: #339933;\">,<\/span> beers<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span><br \/>\u00a0 res.<span style=\"color: #660066;\">send<\/span><span style=\"color: #009900;\">(<\/span>beers<span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><br \/><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/div>\n<\/div>\n<p>We have again collapsed a large amount of vaguely understandable code down to a simple and concise query. \u00a0I believe this begins to show the power of N1QL and why I am personally so excited to see N1QL. \u00a0There is however one caveat I noticed while doing this, and this is that similar to SQL, you need to be careful about what kind of user-data you are passing into your queries. \u00a0I wrote a simple cleaning function to try and prevent any malicious intent (though N1QL is currently read-only anyways), but my cleaning code is by no means extensive. \u00a0Another issue I noticed is that our second query with the LIKE clause executed significantly slower as a N1QL query then it did when using map\/reduce. \u00a0I believe this is simply a result of N1QL still being developer preview, and there is lots of optimizations left to be done by the N1QL team.<\/p>\n<p>If you want to see the fully converted source code, take a look at the n1ql branch of the beersample-node repository available here, https:\/\/github.com\/couchbaselabs\/beersample-node\/tree\/n1ql. \u00a0<\/p>\n<p>Thanks! Brett<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, recently I added support to our Node.js client for executing N1QL queries against your cluster, providing you are running an instance of the N1QL engine (to get a hold of the updated version of the Node.js client with this [&hellip;]<\/p>\n","protected":false},"author":31,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"ppma_author":[9004],"class_list":["post-1725","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"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>Node.js and N1QL - 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\/nodejs-and-n1ql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node.js and N1QL\" \/>\n<meta property=\"og:description\" content=\"So, recently I added support to our Node.js client for executing N1QL queries against your cluster, providing you are running an instance of the N1QL engine (to get a hold of the updated version of the Node.js client with this [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-16T18:55:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/11\/couchbase-nosql-dbaas.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Brett Lawson, Principal Software Engineer, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brett Lawson, Principal Software Engineer, 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\/nodejs-and-n1ql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/\"},\"author\":{\"name\":\"Brett Lawson, Principal Software Engineer, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/5cfc2fbf25776be2a027a474562be02f\"},\"headline\":\"Node.js and N1QL\",\"datePublished\":\"2014-12-16T18:55:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/\"},\"wordCount\":801,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/\",\"name\":\"Node.js and N1QL - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2014-12-16T18:55:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#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\/nodejs-and-n1ql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Node.js and 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\":\"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\/5cfc2fbf25776be2a027a474562be02f\",\"name\":\"Brett Lawson, Principal Software Engineer, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ee3586f0c112c20e863af447d44dec8f\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6aec1ba24ef7558a248dcde7b7a18b15b06e2885b24b663906a448634066c1c4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6aec1ba24ef7558a248dcde7b7a18b15b06e2885b24b663906a448634066c1c4?s=96&d=mm&r=g\",\"caption\":\"Brett Lawson, Principal Software Engineer, Couchbase\"},\"description\":\"Brett Lawson is a Principal Software Engineer at Couchbase. Brett is responsible for the design and development of the Couchbase Node.js and PHP clients as well as playing a role in the design and development of the C library, libcouchbase.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/brett-lawson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Node.js and N1QL - 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\/nodejs-and-n1ql\/","og_locale":"en_US","og_type":"article","og_title":"Node.js and N1QL","og_description":"So, recently I added support to our Node.js client for executing N1QL queries against your cluster, providing you are running an instance of the N1QL engine (to get a hold of the updated version of the Node.js client with this [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/","og_site_name":"The Couchbase Blog","article_published_time":"2014-12-16T18:55:07+00:00","og_image":[{"width":1800,"height":630,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/11\/couchbase-nosql-dbaas.png","type":"image\/png"}],"author":"Brett Lawson, Principal Software Engineer, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Brett Lawson, Principal Software Engineer, Couchbase","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/"},"author":{"name":"Brett Lawson, Principal Software Engineer, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/5cfc2fbf25776be2a027a474562be02f"},"headline":"Node.js and N1QL","datePublished":"2014-12-16T18:55:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/"},"wordCount":801,"commentCount":4,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/","url":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/","name":"Node.js and N1QL - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2014-12-16T18:55:07+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/nodejs-and-n1ql\/#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\/nodejs-and-n1ql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Node.js and 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":"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\/5cfc2fbf25776be2a027a474562be02f","name":"Brett Lawson, Principal Software Engineer, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ee3586f0c112c20e863af447d44dec8f","url":"https:\/\/secure.gravatar.com\/avatar\/6aec1ba24ef7558a248dcde7b7a18b15b06e2885b24b663906a448634066c1c4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6aec1ba24ef7558a248dcde7b7a18b15b06e2885b24b663906a448634066c1c4?s=96&d=mm&r=g","caption":"Brett Lawson, Principal Software Engineer, Couchbase"},"description":"Brett Lawson is a Principal Software Engineer at Couchbase. Brett is responsible for the design and development of the Couchbase Node.js and PHP clients as well as playing a role in the design and development of the C library, libcouchbase.","url":"https:\/\/www.couchbase.com\/blog\/author\/brett-lawson\/"}]}},"authors":[{"term_id":9004,"user_id":31,"is_guest":0,"slug":"brett-lawson","display_name":"Brett Lawson, Principal Software Engineer, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/6aec1ba24ef7558a248dcde7b7a18b15b06e2885b24b663906a448634066c1c4?s=96&d=mm&r=g","author_category":"","last_name":"Lawson","first_name":"Brett","job_title":"","user_url":"","description":"Brett Lawson is a Principal Software Engineer at Couchbase. Brett is responsible for the design and development of the Couchbase Node.js and PHP clients as well as playing a role in the design and development of the C library, libcouchbase."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1725","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\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=1725"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1725\/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=1725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=1725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=1725"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}