javascript - How to do a conversion of a RegEx sql query from: SQL Query to Couchbase NoSQL? -
this question has answer here:
- similar sql statement in couchbase 2 answers
i new couchbase , i'm quite confused regular expression of javascript. not know how write query in javascript couchbase nosql contains regular expression.
i have sql query:
select * table name ‘abc%’;
i want search records starts 'abc', 'abc', etc (case doesn't matter). example matches are: "abc ...", "abc...", "abc anything".
in couchbase 3 , below
you'd have have view
emits name
. here, use sdks or rest api query view.
note can "starts with" views, using startkey
, endkey
\u0000
suffix endkeys (see this other answer).
also default views case sensitive, have normalize emitted data, in case instead of emitting name
field in json (doc.name
) is, emit doc.name.tolowercase()
. query view with:
startkey="abc"&endkey="abc\u0000"
in couchbase 4 (in beta): n1ql!
with couchbase 4 beta comes n1ql
, sql documents! can like
queries it. in fact pretty close sql version since n1ql superset of sql (sql++
):
select * thebucketcontainingusers type = "user" , lower(name) "abc%"
i included type
constraint because in couchbase store different kinds of documents in single bucket , 1 way of separating them include kind of type field in doc itself.
Comments
Post a Comment