Reputation: 2289
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
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
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