Query Builder for N1QL


#1

Anyone scratched up a query builder for n1ql in NodeJS? I’ve utilized some query builders in the past but I haven’t come across any for n1ql.

Thanks,

Corey


N1QL Node.js fluent API
#2

Via Brett from another case (re fluent api / query builder):

Hey @corey_perkins,

Unfortunately, while Java’s import semantics allow them to import methods globally into their scope to allow you write concise expressive queries directly in Java; until recently, Node.js did not have such an equivalence. Specifically, in Java you are able to write something like import * from couchbase.n1ql and then use e('$age') , in Node.js you would have to write something far longer and less concise: N1qlQuery.e('$age') , while alone this does not seem like a significant difference, it was our experience that using these longer names simply increased complexity on any queries you were looking to dynamically generate.

That all being said. Some recently Javascript features such as modules have made this situation far better, and there may be an opportunity to build an extension library which provides query building as Java does. If you were interested, we could put together an extension library like this together using the Java DSL as a strong base for the semantics. Let me know if you are interested and I can throw together a starting point to use in relatively short order.

Cheers, Brett


#3

@brett19 This sounds like an excellent idea, myself and my team would be extremely interested!

Looking forward to it!

Thanks,

Corey


#4

Hey @corey_perkins,
After looking at the Java query DSL, it might take me a little bit more time than expected to put together something here. I’ve begun to work on it, but there is a lot more code than I expected. You can find the Java DSL code here: https://github.com/couchbase/couchbase-java-client/tree/master/src/main/java/com/couchbase/client/java/query/dsl .
Cheers, Brett


#5

Brett,

Thanks for the intel, I’ve been studying the java implementation and I could certainly contribute. Keep me posted as you scratch-up a starting point and I’ll be glad to jump in.

Thanks a ton!

Corey Perkins