Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Couchbase Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
Couchbase Essentials

Couchbase Essentials

By : John C Zablocki
3 (2)
close
close
Couchbase Essentials

Couchbase Essentials

3 (2)
By: John C Zablocki

Overview of this book

This book is for those application developers who want to achieve greater flexibility and scalability from their software. Whether you are familiar with other NoSQL databases or have only used relational systems, this book will provide you with enough background to move you along at your own pace. If you are new to NoSQL document databases, the design discussions and introductory material will give you the information you need to get started with Couchbase.
Table of Contents (10 chapters)
close
close
9
Index

Compound indexes


Writing an AND query requires a different approach than what we used for our OR query. If you wanted to perform the analogue of a SQL query with multiple values in a WHERE clause, you'd need to structure your view keys in such a way as to allow your application to supply multiple values as one key parameter value:

SELECT * 
FROM Users 
WHERE LastName = 'Soprano' AND FirstName = 'Tony'

In the preceding SQL statement, we are able to have values for both LastName and FirstName. One approach would be to create a delimited key in our index like this:

function(doc, meta) {
  if (doc.type == "user" && doc.firstName && doc.lastName) {
    emit(doc.lastName + "," + doc.firstName, null);
  }
}

This map function emits a key in the form of "Soprano,Tony" to the index. When querying the index, the client application would concatenate the last name, a comma, and the first name. The resulting string would be provided as the argument for the key parameter.

Obviously, it's not...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY