M.S.Naidu
M.S.Naidu

Reputation: 2289

What is the Equvalent N1ql query for inserting the document in the couchbase

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?

Upvotes: 3

Views: 421

Answers (2)

Simon Baslé
Simon Baslé

Reputation: 28351

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

Upvotes: 4

Jerod Johnson
Jerod Johnson

Reputation: 784

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.

Upvotes: 0

Related Questions