6

I am using Couchbase 4.0 beta with java-client 2.1.3.

The Bucket.get(id) returns JsonDocument from which I can get id and cas as well as the content. Now I want to query on secondary indices using N1QL (select *). However, the QueryResult only returns rows of JsonObjects which are just the document contents. Is there anyway I can get the meta data (id and cas) too?

o11c
  • 15,265
  • 4
  • 50
  • 75
P T
  • 75
  • 2
  • 5

1 Answers1

9

You can do the following:

SELECT b, meta(b) AS meta FROM my_bucket b;
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
geraldss
  • 2,415
  • 1
  • 11
  • 12
  • is there a way to get the id field directly using the get call? I think there is an extra overhead of going through the query service if you use SELECT query statement – 500865 Jan 26 '21 at 11:59