Learn N1QL by sample
N1QL is the document query language used to query data in Couchbase Server (CB). N1QL will be an integrated part of CB 4, until then there is a preview version available.
SQL for JSON Documents
N1QL is the first language to combine the flexibility of JSON with power of SQL queries. With N1QL you can run SQL like queries against your CB data without the need to pre-build views. N1QL enables advanced ad-hoc document queries in a familiar query language.
With every new language there is a something new to learn, N1QL is no exception but the learning curve is modest as N1QL is highly inspired by SQL. The most notable difference is some added key words and the fact that N1QL is designed for working with JSON documents. This will get very visible when inserting data.
It’s different how we learn, but for me there is nothing that beats a good set of samples that showcase the options in the language and print out some meaningful data that I can reproduce on my local box.
The samples presented here are based on the “travel-sample” data that ships with Couchbase Server 4 Beta. Therefore if you install CB 4 Beta (or above), then please remember to install the “travel-sample” data bucket as well.
I will continue to expand the samples when I find something missing or whenever someone points out a missing sample. Therefore I would like to invite you to suggest samples that you are missing or find incomplete.
N1QL language reference
The full N1QL language reference can be found here: http://docs.couchbase.com/4.0/n1ql/n1ql-language-reference/index.html
I hope you find the samples use full and tweakable for use in your own project.