- Section 1: Basics
- 2: User-friendly language
- 3: Documents, not rows
- 4: Pattern matching with LIKE
- 5: Matching elements in nested arrays with ANY
- 6: Combining multiple conditions with AND
- 7: Querying primary keys
- 8: Quick review
- 9: Pagination with LIMIT and OFFSET
- 10: Filtering grouped data with HAVING
- 11. Review
- 12. Section 2: Joins
- 13. Joins
- 14. Joins
- 15. Exercise
- 16. Exercise
- 17. NEST
- 18. Chaining JOINs
- 19. Example
- 20. Array Comprehensions
- 21. Section 3: DML Statements
- 22. Nest
- 23. Nest
- 24. UNNEST
- 25. Filtering on nested data
- 26. Subquery
- 27. Subquery
- 28. UPDATE
- 29. Case Study I. E-Commerce
- 30. Shopper - Browsing products from page to page
- 31. Shopper - Listing product categories
- 32. Shopper - Browsing and searching for a product
- 33. Shopper - Listing products in a category
- 34. Shopper - Finding the most popular products in a category
- 35. Shopper - Browsing products and sorting results
- 36. Shopper - Shopping at a one-day sale
- 37. Shopper - Listing the top 10 best selling products
- 38. Shopper - Listing the highest rated products
- 39. Merchant - Preparing a purchase order
- 40. Merchant - Finding the most valued shoppers
- 41. Merchant - Reporting customers by region
- 42. Merchant - Reporting the active monthly customers
- 43. Merchant - Identifying non-performing products
- 44. Merchant - Generating the month-over-month sales report
- 45. Merchant - Big ticket orders
- 46. Case Study II . Social Game
- 47. Assembling and loading user profiles
- 48. Listing messages sent by a user
- 49. Generating scoreboards
If you're' familiar with standard SQL, then picking up N1QL will be easy.
A simple query in N1QL has three parts to it:
Only a SELECT clause is required in a query. The wildcard * selects all top-level fields of the document. Queries can return a collection of different document structures or fragments, however they will all match the conditions in the WHERE clause.
Remember that there is no schema in Couchbase. N1QL is flexible enough to return all results that match your query, even if they vary in structure.
If you change the * to a document field such as “children” you will see the query return a collection of appropriate fragments of each document.
Try the next sample query where we find all documents where the name is 'Ian'.
A simple query in N1QL has three parts to it:
- SELECT — Parts of document to return
- FROM — The data bucket, or data store to work with
- WHERE— Conditions the document must satisfy
Only a SELECT clause is required in a query. The wildcard * selects all top-level fields of the document. Queries can return a collection of different document structures or fragments, however they will all match the conditions in the WHERE clause.
Remember that there is no schema in Couchbase. N1QL is flexible enough to return all results that match your query, even if they vary in structure.
If you change the * to a document field such as “children” you will see the query return a collection of appropriate fragments of each document.
Try the next sample query where we find all documents where the name is 'Ian'.
To run this example, click the button in the top right corner of the code editor.