@@ -27,7 +27,7 @@ The code samples below will use these imports:
2727
2828[source,java]
2929----
30- include::example$KvOperations.java[tag=imports]
30+ include::devguide: example$java/ KvOperations.java[tag=imports]
3131----
3232
3333[TIP]
@@ -61,7 +61,7 @@ We'll use the built-in JSON types for simplicity, but you can use different type
6161
6262[source,java]
6363----
64- include::example$KvOperations.java[tag=upsert,indent=0]
64+ include::devguide: example$java/ KvOperations.java[tag=upsert,indent=0]
6565----
6666
6767[NOTE]
@@ -73,7 +73,7 @@ They can be accessed like this:
7373
7474[source,java]
7575----
76- include::example$KvOperations.java[tag=apis,indent=0]
76+ include::devguide: example$java/ KvOperations.java[tag=apis,indent=0]
7777----
7878=====
7979
@@ -82,7 +82,7 @@ Insert works very similarly to upsert, but will fail if the document already exi
8282
8383[source,java]
8484----
85- include::example$KvOperations.java[tag=insert,indent=0]
85+ include::devguide: example$java/ KvOperations.java[tag=insert,indent=0]
8686----
8787
8888== Retrieving documents
@@ -91,14 +91,14 @@ We've tried upserting and inserting documents into Couchbase Server, let's get t
9191
9292[source,java]
9393----
94- include::example$KvOperations.java[tag=get-simple,indent=0]
94+ include::devguide: example$java/ KvOperations.java[tag=get-simple,indent=0]
9595----
9696
9797Of course if we're getting a document we probably want to do something with the content:
9898
9999[source,java]
100100----
101- include::example$KvOperations.java[tag=get,indent=0]
101+ include::devguide: example$java/ KvOperations.java[tag=get,indent=0]
102102----
103103
104104Once we have a `GetResult`, we can use `contentAsObject()` to turn the content back into a `JsonObject` like we inserted it in the examples before,
@@ -110,7 +110,7 @@ A very common sequence of operations is to `get` a document, modify its contents
110110
111111[source,java]
112112----
113- include::example$KvOperations.java[tag=replace,indent=0]
113+ include::devguide: example$java/ KvOperations.java[tag=replace,indent=0]
114114----
115115
116116We `upsert` an initial version of the document.
@@ -136,7 +136,7 @@ Let's see a more advanced `replace` example that shows one way to handle this:
136136
137137[source,java]
138138----
139- include::example$KvOperations.java[tag=replace-retry,indent=0]
139+ include::devguide: example$java/ KvOperations.java[tag=replace-retry,indent=0]
140140----
141141
142142Note that this code is simplistic to show how CAS retry works in general.
@@ -153,7 +153,7 @@ Removing a document is straightforward:
153153
154154[source,java]
155155----
156- include::example$KvOperations.java[tag=remove,indent=0]
156+ include::devguide: example$java/ KvOperations.java[tag=remove,indent=0]
157157----
158158
159159Like `replace`, `remove` also optionally takes the CAS value if you want to make sure you are only removing the document if it hasn't changed since you last fetched it.
@@ -169,7 +169,7 @@ It can be used like this:
169169
170170[source,java]
171171----
172- include::example$KvOperations.java[tag=durability,indent=0]
172+ include::devguide: example$java/ KvOperations.java[tag=durability,indent=0]
173173----
174174
175175If no argument is provided the application will report success back as soon as the primary node has acknowledged the mutation in its memory.
@@ -195,7 +195,7 @@ This can be achieved like this:
195195
196196[source,java]
197197----
198- include::example$KvOperations.java[tag=durability-observed,indent=0]
198+ include::devguide: example$java/ KvOperations.java[tag=durability-observed,indent=0]
199199----
200200
201201To stress, durability is a useful feature but should not be the default for most applications, as there is a performance consideration,
@@ -211,7 +211,7 @@ You can set an expiry value from a `Duration` when creating a document:
211211
212212[source,java]
213213----
214- include::example$KvOperations.java[tag=expiry-insert,indent=0]
214+ include::devguide: example$java/ KvOperations.java[tag=expiry-insert,indent=0]
215215----
216216
217217The expiry may be specified as a `Duration` only if the provided value is less than 50 years.
@@ -220,38 +220,38 @@ For expiration more than 50 years in the future, or if you have already calculat
220220
221221[source,java]
222222----
223- include::example$KvOperations.java[tag=expiry-insert-instant,indent=0]
223+ include::devguide: example$java/ KvOperations.java[tag=expiry-insert-instant,indent=0]
224224----
225225
226226When getting a document from Couchbase Server, the expiry is not included by default, but it can be requested
227227by setting the `withExpiry` option to true:
228228
229229[source,java]
230230----
231- include::example$KvOperations.java[tag=expiry-get,indent=0]
231+ include::devguide: example$java/ KvOperations.java[tag=expiry-get,indent=0]
232232----
233233
234234Note that when updating the document, special care must be taken to avoid resetting the expiry to zero.
235235If you are using Couchbase Server 7.0 or later, set the `preserveExpiry` option when updating the document:
236236
237237[source,java]
238238----
239- include::example$KvOperations.java[tag=preserve-expiry,indent=0]
239+ include::devguide: example$java/ KvOperations.java[tag=preserve-expiry,indent=0]
240240----
241241
242242Prior to Couchbase 7.0, it's necessary to fetch the previous expiry and set it again:
243243
244244[source,java]
245245----
246- include::example$KvOperations.java[tag=expiry-replace,indent=0]
246+ include::devguide: example$java/ KvOperations.java[tag=expiry-replace,indent=0]
247247----
248248
249249Some applications may find `getAndTouch` useful, which fetches a document while updating its expiry field.
250250It can be used like this:
251251
252252[source,java]
253253----
254- include::example$KvOperations.java[tag=expiry-touch,indent=0]
254+ include::devguide: example$java/ KvOperations.java[tag=expiry-touch,indent=0]
255255----
256256
257257
@@ -303,7 +303,7 @@ Here is an example showing an upsert in the `users` collection, which lives in t
303303
304304[source,java]
305305----
306- include::example$KvOperations.java[tag=named-collection-upsert,indent=0]
306+ include::devguide: example$java/ KvOperations.java[tag=named-collection-upsert,indent=0]
307307----
308308
309309
@@ -325,7 +325,7 @@ Here's an example of a KV range scan that gets all documents in a collection:
325325.KV Range Scan for all documents in a collection
326326[source,java]
327327----
328- include::example$KvOperations.java[tag=rangeScanAllDocuments,indent=0]
328+ include::devguide: example$java/ KvOperations.java[tag=rangeScanAllDocuments,indent=0]
329329----
330330<1> The `ScanType.rangeScan()` method has two nullable parameters: `from` and `to`.
331331If you pass null like in this example, you'll get all documents in the collection.
@@ -346,7 +346,7 @@ For example, to get all documents associated with user "alice", you would write:
346346.KV Range Scan for all documents in a collection whose IDs start with "alice::"
347347[source,java]
348348----
349- include::example$KvOperations.java[tag=rangeScanPrefix,indent=0]
349+ include::devguide: example$java/ KvOperations.java[tag=rangeScanPrefix,indent=0]
350350----
351351<1> Note the scan type is *prefixScan*.
352352
@@ -358,7 +358,7 @@ If you want to get random documents from a collection, use a sample scan.
358358.KV Range Scan for 100 random documents
359359[source,java]
360360----
361- include::example$KvOperations.java[tag=rangeScanSample,indent=0]
361+ include::devguide: example$java/ KvOperations.java[tag=rangeScanSample,indent=0]
362362----
363363<1> In this example, no more than `100` documents are returned.
364364
@@ -370,7 +370,7 @@ If you only want the document IDs, set the `idsOnly` option to true, like this:
370370.KV Range Scan for all document IDs in a collection
371371[source,java]
372372----
373- include::example$KvOperations.java[tag=rangeScanAllDocumentIds,indent=0]
373+ include::devguide: example$java/ KvOperations.java[tag=rangeScanAllDocumentIds,indent=0]
374374----
375375<1> The returned `ScanResult` objects throw `NoSuchElementException` if you try to access any property other than `id`.
376376
0 commit comments