3

The following query is for fetching the documents from the couchbase while working with Java_client

 N1qlQueryResult result = bucket.query(N1qlQuery.simple(
                    "SELECT * FROM `default;"));

How to write the statement to insert the docs into Couchbase using N1qlQuery like above?

M.S.Naidu
  • 2,239
  • 5
  • 32
  • 56

2 Answers2

4

Since 4.1, N1QL also have INSERT and UPSERT statements that you can use to create documents. See the reference (INSERT)

Simon Baslé
  • 27,105
  • 5
  • 69
  • 70
0

You can insert a document using the insert(...) method from the Bucket class. For example:

JSONDocument resultDoc = bucket.insert(JSONDocument.create(myId, myJSONDocument));

where both myId and myJSONDocument are strings.

For future reference, you can always refer to the Couchbase JAVA SDK.

Jerod Johnson
  • 764
  • 7
  • 15