Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Couchbase Essentials

You're reading from  Couchbase Essentials

Product type Book
Published in Feb 2015
Publisher
ISBN-13 9781784394493
Pages 170 pages
Edition 1st Edition
Languages

String utilities


One of the more obvious limitations of querying views is the lack of a proper LIKE operator. Though we saw in Chapter 4, Advanced Views, that it is possible to emulate a query like "starts with", it is not as robust as SQL's LIKE operator.

Fortunately, N1QL addresses this limitation with its own LIKE operator. Similar to SQL, you define a search pattern with a wildcard that is specified by a % character. In the following snippet, all breweries with Boston in their name will be returned in the results:

SELECT *
FROM brewery-sample
WHERE type = "brewery"
AND name LIKE "%Boston%"

Other string operators exist to perform standard string transformations such as SUBSTR, LOWER, UPPER, and LENGTH. You can use these functions as you do in a JavaScript map function or with string operations in most frameworks:

SELECT *
FROM beer-sample
WHERE type = "brewery"
AND LOWER(name) ="thomas hooker brewing"

It's also possible to perform string concatenation using the double pipe (||) operator. You...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}