0

I want to execute a Nickel Query in my project and want to convert all the task that I am actually doing using view to perform it with Nickel. Is it possible..??

If yes please provide it with an example and for executing the Nickel queries in Scala,and do I have to add any additional dependencies in my project. If yes please provide the link too.

Any suggestions are appreciated

Shivansh
  • 3,454
  • 23
  • 46
  • What have you tried yourself? Would be nice to see what options you have tried before asking for help. – cmbaxter Jul 14 '15 at 15:26

1 Answers1

3

We are planning/working on a scala driver, but right now you can just use the java SDK through scala pretty easily. So I recommend you to follow the official docs, but convert the java examples to scala: http://docs.couchbase.com/developer/java-2.1/java-intro.html

You want the java-client dependency first:

libraryDependencies := "com.couchbase.client" % "java-client" % "2.1.4"

If you use the implict conversions, you can make your life a little easier too:

import com.couchbase.client.java.CouchbaseCluster
import com.couchbase.client.java.query.Query
import scala.collection.JavaConversions._

object ConnectAndQuery {

  def main(args: Array[String]): Unit = {
    val cluster = CouchbaseCluster.create()
    val bucket = cluster.openBucket("travel-sample")

    val result = bucket.query(Query.simple("SELECT * FROM `travel-sample`LIMIT 10"))
    result.allRows().map(_.value()).foreach(println)

    cluster.disconnect()
  }

}
daschl
  • 1,124
  • 6
  • 11
  • Yeah I have used it already but its not working and after some research i found out that we can't query a password protected bucket using N1ql.. Its an issue in couchbase and I think soon they will update this. – Shivansh Jul 15 '15 at 13:06
  • With 2.1.3 and later you should be able do to that from the SDK (https://www.couchbase.com/issues/browse/JVMCBC-188) – daschl Jul 22 '15 at 08:29