couchbase 3.0.0.beta.1-universal-darwin-19 → 3.0.0-universal-darwin-19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +227 -0
- data/.rubocop_todo.yml +47 -0
- data/CONTRIBUTING.md +110 -0
- data/Gemfile +4 -0
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/couchbase.gemspec +40 -39
- data/examples/analytics.rb +123 -108
- data/examples/auth.rb +33 -0
- data/examples/crud.rb +16 -2
- data/examples/managing_analytics_indexes.rb +18 -4
- data/examples/managing_buckets.rb +17 -3
- data/examples/managing_collections.rb +22 -9
- data/examples/managing_query_indexes.rb +38 -18
- data/examples/managing_search_indexes.rb +21 -6
- data/examples/managing_view_indexes.rb +18 -4
- data/examples/query.rb +17 -3
- data/examples/query_with_consistency.rb +30 -20
- data/examples/search.rb +116 -101
- data/examples/search_with_consistency.rb +43 -30
- data/examples/subdocument.rb +42 -30
- data/examples/view.rb +19 -10
- data/ext/CMakeLists.txt +40 -2
- data/ext/build_version.hxx.in +1 -1
- data/ext/couchbase/bucket.hxx +190 -38
- data/ext/couchbase/cluster.hxx +22 -4
- data/ext/couchbase/configuration.hxx +14 -14
- data/ext/couchbase/couchbase.cxx +108 -12
- data/ext/couchbase/error_map.hxx +202 -2
- data/ext/couchbase/errors.hxx +8 -2
- data/ext/couchbase/io/dns_client.hxx +6 -6
- data/ext/couchbase/io/http_command.hxx +2 -2
- data/ext/couchbase/io/http_session.hxx +7 -11
- data/ext/couchbase/io/http_session_manager.hxx +3 -3
- data/ext/couchbase/io/mcbp_command.hxx +101 -44
- data/ext/couchbase/io/mcbp_session.hxx +144 -49
- data/ext/couchbase/io/retry_action.hxx +30 -0
- data/ext/couchbase/io/retry_context.hxx +39 -0
- data/ext/couchbase/io/retry_orchestrator.hxx +96 -0
- data/ext/couchbase/io/retry_reason.hxx +235 -0
- data/ext/couchbase/io/retry_strategy.hxx +156 -0
- data/ext/couchbase/operations/document_decrement.hxx +2 -0
- data/ext/couchbase/operations/document_exists.hxx +2 -0
- data/ext/couchbase/operations/document_get.hxx +2 -0
- data/ext/couchbase/operations/document_get_and_lock.hxx +2 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +2 -0
- data/ext/couchbase/operations/document_get_projected.hxx +2 -0
- data/ext/couchbase/operations/document_increment.hxx +2 -0
- data/ext/couchbase/operations/document_insert.hxx +2 -0
- data/ext/couchbase/operations/document_lookup_in.hxx +2 -0
- data/ext/couchbase/operations/document_mutate_in.hxx +3 -0
- data/ext/couchbase/operations/document_query.hxx +10 -0
- data/ext/couchbase/operations/document_remove.hxx +2 -0
- data/ext/couchbase/operations/document_replace.hxx +2 -0
- data/ext/couchbase/operations/document_search.hxx +8 -3
- data/ext/couchbase/operations/document_touch.hxx +2 -0
- data/ext/couchbase/operations/document_unlock.hxx +2 -0
- data/ext/couchbase/operations/document_upsert.hxx +2 -0
- data/ext/couchbase/operations/query_index_create.hxx +14 -4
- data/ext/couchbase/operations/query_index_drop.hxx +12 -2
- data/ext/couchbase/operations/query_index_get_all.hxx +11 -2
- data/ext/couchbase/origin.hxx +47 -17
- data/ext/couchbase/platform/backtrace.c +189 -0
- data/ext/couchbase/platform/backtrace.h +54 -0
- data/ext/couchbase/platform/terminate_handler.cc +122 -0
- data/ext/couchbase/platform/terminate_handler.h +36 -0
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +6 -1
- data/ext/couchbase/protocol/status.hxx +14 -4
- data/ext/couchbase/version.hxx +2 -2
- data/ext/extconf.rb +39 -36
- data/ext/test/main.cxx +64 -16
- data/lib/couchbase.rb +0 -1
- data/lib/couchbase/analytics_options.rb +2 -4
- data/lib/couchbase/authenticator.rb +14 -0
- data/lib/couchbase/binary_collection.rb +9 -9
- data/lib/couchbase/binary_collection_options.rb +8 -6
- data/lib/couchbase/bucket.rb +18 -18
- data/lib/couchbase/cluster.rb +121 -90
- data/lib/couchbase/collection.rb +36 -38
- data/lib/couchbase/collection_options.rb +31 -17
- data/lib/couchbase/common_options.rb +1 -1
- data/lib/couchbase/datastructures/couchbase_list.rb +16 -16
- data/lib/couchbase/datastructures/couchbase_map.rb +18 -18
- data/lib/couchbase/datastructures/couchbase_queue.rb +13 -13
- data/lib/couchbase/datastructures/couchbase_set.rb +8 -7
- data/lib/couchbase/errors.rb +10 -3
- data/lib/couchbase/json_transcoder.rb +2 -2
- data/lib/couchbase/libcouchbase.bundle +0 -0
- data/lib/couchbase/management/analytics_index_manager.rb +37 -37
- data/lib/couchbase/management/bucket_manager.rb +25 -25
- data/lib/couchbase/management/collection_manager.rb +3 -3
- data/lib/couchbase/management/query_index_manager.rb +59 -14
- data/lib/couchbase/management/search_index_manager.rb +15 -12
- data/lib/couchbase/management/user_manager.rb +1 -1
- data/lib/couchbase/management/view_index_manager.rb +11 -5
- data/lib/couchbase/mutation_state.rb +12 -0
- data/lib/couchbase/query_options.rb +23 -9
- data/lib/couchbase/scope.rb +61 -1
- data/lib/couchbase/search_options.rb +40 -27
- data/lib/couchbase/subdoc.rb +31 -28
- data/lib/couchbase/version.rb +2 -2
- data/lib/couchbase/view_options.rb +0 -1
- metadata +20 -7
data/lib/couchbase/collection.rb
CHANGED
@@ -22,7 +22,7 @@ module Couchbase
|
|
22
22
|
attr_reader :scope_name
|
23
23
|
attr_reader :name
|
24
24
|
|
25
|
-
|
25
|
+
alias inspect to_s
|
26
26
|
|
27
27
|
# @param [Couchbase::Backend] backend
|
28
28
|
# @param [String] bucket_name name of the bucket
|
@@ -140,7 +140,7 @@ module Couchbase
|
|
140
140
|
# @return [MutationResult]
|
141
141
|
def remove(id, options = RemoveOptions.new)
|
142
142
|
resp = @backend.document_remove(bucket_name, "#{@scope_name}.#{@name}", id, options.timeout, {
|
143
|
-
|
143
|
+
durability_level: options.durability_level,
|
144
144
|
})
|
145
145
|
MutationResult.new do |res|
|
146
146
|
res.cas = resp[:cas]
|
@@ -158,8 +158,8 @@ module Couchbase
|
|
158
158
|
def insert(id, content, options = InsertOptions.new)
|
159
159
|
blob, flags = options.transcoder.encode(content)
|
160
160
|
resp = @backend.document_insert(bucket_name, "#{@scope_name}.#{@name}", id, options.timeout, blob, flags, {
|
161
|
-
|
162
|
-
|
161
|
+
durability_level: options.durability_level,
|
162
|
+
expiry: options.expiry,
|
163
163
|
})
|
164
164
|
MutationResult.new do |res|
|
165
165
|
res.cas = resp[:cas]
|
@@ -177,8 +177,8 @@ module Couchbase
|
|
177
177
|
def upsert(id, content, options = UpsertOptions.new)
|
178
178
|
blob, flags = options.transcoder.encode(content)
|
179
179
|
resp = @backend.document_upsert(bucket_name, "#{@scope_name}.#{@name}", id, options.timeout, blob, flags, {
|
180
|
-
|
181
|
-
|
180
|
+
durability_level: options.durability_level,
|
181
|
+
expiry: options.expiry,
|
182
182
|
})
|
183
183
|
MutationResult.new do |res|
|
184
184
|
res.cas = resp[:cas]
|
@@ -196,9 +196,9 @@ module Couchbase
|
|
196
196
|
def replace(id, content, options = ReplaceOptions.new)
|
197
197
|
blob, flags = options.transcoder.encode(content)
|
198
198
|
resp = @backend.document_replace(bucket_name, "#{@scope_name}.#{@name}", id, options.timeout, blob, flags, {
|
199
|
-
|
200
|
-
|
201
|
-
|
199
|
+
durability_level: options.durability_level,
|
200
|
+
expiry: options.expiry,
|
201
|
+
cas: options.cas,
|
202
202
|
})
|
203
203
|
MutationResult.new do |res|
|
204
204
|
res.cas = resp[:cas]
|
@@ -240,14 +240,14 @@ module Couchbase
|
|
240
240
|
# @return [LookupInResult]
|
241
241
|
def lookup_in(id, specs, options = LookupInOptions.new)
|
242
242
|
resp = @backend.document_lookup_in(
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
}
|
243
|
+
bucket_name, "#{@scope_name}.#{@name}", id, options.timeout, options.access_deleted,
|
244
|
+
specs.map do |s|
|
245
|
+
{
|
246
|
+
opcode: s.type,
|
247
|
+
xattr: s.xattr?,
|
248
|
+
path: s.path,
|
250
249
|
}
|
250
|
+
end
|
251
251
|
)
|
252
252
|
LookupInResult.new do |res|
|
253
253
|
res.transcoder = options.transcoder
|
@@ -275,26 +275,26 @@ module Couchbase
|
|
275
275
|
# @return [MutateInResult]
|
276
276
|
def mutate_in(id, specs, options = MutateInOptions.new)
|
277
277
|
resp = @backend.document_mutate_in(
|
278
|
-
|
279
|
-
|
280
|
-
{
|
281
|
-
opcode: s.type,
|
282
|
-
path: s.path,
|
283
|
-
param: s.param,
|
284
|
-
xattr: s.xattr?,
|
285
|
-
expand_macros: s.expand_macros?,
|
286
|
-
create_path: s.create_path?
|
287
|
-
}
|
288
|
-
},
|
278
|
+
bucket_name, "#{@scope_name}.#{@name}", id, options.timeout,
|
279
|
+
specs.map do |s|
|
289
280
|
{
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
281
|
+
opcode: s.type,
|
282
|
+
path: s.path,
|
283
|
+
param: s.param,
|
284
|
+
xattr: s.xattr?,
|
285
|
+
expand_macros: s.expand_macros?,
|
286
|
+
create_path: s.create_path?,
|
295
287
|
}
|
288
|
+
end,
|
289
|
+
{
|
290
|
+
durability_level: options.durability_level,
|
291
|
+
store_semantics: options.store_semantics,
|
292
|
+
access_deleted: options.access_deleted,
|
293
|
+
cas: options.cas,
|
294
|
+
expiry: options.expiry,
|
295
|
+
}
|
296
296
|
)
|
297
|
-
|
297
|
+
result = MutateInResult.new do |res|
|
298
298
|
res.transcoder = options.transcoder
|
299
299
|
res.cas = resp[:cas]
|
300
300
|
res.mutation_token = extract_mutation_token(resp)
|
@@ -310,11 +310,9 @@ module Couchbase
|
|
310
310
|
end
|
311
311
|
end
|
312
312
|
end
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
raise res.first_error
|
317
|
-
end
|
313
|
+
raise result.first_error unless result.success?
|
314
|
+
|
315
|
+
result
|
318
316
|
end
|
319
317
|
|
320
318
|
private
|
@@ -28,6 +28,7 @@ module Couchbase
|
|
28
28
|
|
29
29
|
# @yieldparam [GetOptions] self
|
30
30
|
def initialize
|
31
|
+
super
|
31
32
|
@transcoder = JsonTranscoder.new
|
32
33
|
@preserve_array_indexes = false
|
33
34
|
@with_expiry = nil
|
@@ -67,6 +68,7 @@ module Couchbase
|
|
67
68
|
|
68
69
|
# @yieldparam [GetAndLockOptions] self
|
69
70
|
def initialize
|
71
|
+
super
|
70
72
|
@transcoder = JsonTranscoder.new
|
71
73
|
yield self if block_given?
|
72
74
|
end
|
@@ -78,6 +80,7 @@ module Couchbase
|
|
78
80
|
|
79
81
|
# @yieldparam [GetAndTouchOptions] self
|
80
82
|
def initialize
|
83
|
+
super
|
81
84
|
@transcoder = JsonTranscoder.new
|
82
85
|
yield self if block_given?
|
83
86
|
end
|
@@ -122,6 +125,7 @@ module Couchbase
|
|
122
125
|
|
123
126
|
# @yieldparam [GetAllReplicasOptions] self
|
124
127
|
def initialize
|
128
|
+
super
|
125
129
|
yield self if block_given?
|
126
130
|
end
|
127
131
|
end
|
@@ -132,6 +136,7 @@ module Couchbase
|
|
132
136
|
|
133
137
|
# @yieldparam [GetAnyReplicaOptions] self
|
134
138
|
def initialize
|
139
|
+
super
|
135
140
|
yield self if block_given?
|
136
141
|
end
|
137
142
|
end
|
@@ -139,12 +144,13 @@ module Couchbase
|
|
139
144
|
class GetReplicaResult < GetResult
|
140
145
|
# @return [Boolean] true if this result came from a replica
|
141
146
|
attr_accessor :is_replica
|
142
|
-
|
147
|
+
alias replica? is_replica
|
143
148
|
end
|
144
149
|
|
145
150
|
class ExistsOptions < CommonOptions
|
146
151
|
# @yieldparam [ExistsOptions] self
|
147
152
|
def initialize
|
153
|
+
super
|
148
154
|
yield self if block_given?
|
149
155
|
end
|
150
156
|
end
|
@@ -181,6 +187,7 @@ module Couchbase
|
|
181
187
|
|
182
188
|
# @yieldparam [RemoveOptions]
|
183
189
|
def initialize
|
190
|
+
super
|
184
191
|
@durability_level = :none
|
185
192
|
yield self if block_given?
|
186
193
|
end
|
@@ -198,6 +205,7 @@ module Couchbase
|
|
198
205
|
|
199
206
|
# @yieldparam [InsertOptions]
|
200
207
|
def initialize
|
208
|
+
super
|
201
209
|
@transcoder = JsonTranscoder.new
|
202
210
|
@durability_level = :none
|
203
211
|
yield self if block_given?
|
@@ -216,6 +224,7 @@ module Couchbase
|
|
216
224
|
|
217
225
|
# @yieldparam [UpsertOptions]
|
218
226
|
def initialize
|
227
|
+
super
|
219
228
|
@transcoder = JsonTranscoder.new
|
220
229
|
@durability_level = :none
|
221
230
|
yield self if block_given?
|
@@ -237,6 +246,7 @@ module Couchbase
|
|
237
246
|
|
238
247
|
# @yieldparam [ReplaceOptions]
|
239
248
|
def initialize
|
249
|
+
super
|
240
250
|
@transcoder = JsonTranscoder.new
|
241
251
|
@durability_level = :none
|
242
252
|
yield self if block_given?
|
@@ -259,6 +269,7 @@ module Couchbase
|
|
259
269
|
class TouchOptions < CommonOptions
|
260
270
|
# @yieldparam [TouchOptions] self
|
261
271
|
def initialize
|
272
|
+
super
|
262
273
|
yield self if block_given?
|
263
274
|
end
|
264
275
|
end
|
@@ -266,6 +277,7 @@ module Couchbase
|
|
266
277
|
class UnlockOptions < CommonOptions
|
267
278
|
# @yieldparam [UnlockOptions] self
|
268
279
|
def initialize
|
280
|
+
super
|
269
281
|
yield self if block_given?
|
270
282
|
end
|
271
283
|
end
|
@@ -279,6 +291,7 @@ module Couchbase
|
|
279
291
|
|
280
292
|
# @yieldparam [LookupInOptions] self
|
281
293
|
def initialize
|
294
|
+
super
|
282
295
|
@transcoder = JsonTranscoder.new
|
283
296
|
yield self if block_given?
|
284
297
|
end
|
@@ -320,13 +333,12 @@ module Couchbase
|
|
320
333
|
private
|
321
334
|
|
322
335
|
def get_field_at_index(index)
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
end
|
336
|
+
raise Error::PathInvalid, "Index is out of bounds: #{index}" unless index >= 0 && index < encoded.size
|
337
|
+
|
338
|
+
field = encoded[index]
|
339
|
+
raise field.error unless field.success?
|
340
|
+
|
341
|
+
field
|
330
342
|
end
|
331
343
|
end
|
332
344
|
|
@@ -357,6 +369,7 @@ module Couchbase
|
|
357
369
|
|
358
370
|
# @yieldparam [MutateInOptions]
|
359
371
|
def initialize
|
372
|
+
super
|
360
373
|
@durability_level = :none
|
361
374
|
@store_semantics = :replace
|
362
375
|
@transcoder = JsonTranscoder.new
|
@@ -383,6 +396,7 @@ module Couchbase
|
|
383
396
|
|
384
397
|
# @yieldparam [MutateInResult] self
|
385
398
|
def initialize
|
399
|
+
super
|
386
400
|
yield self if block_given?
|
387
401
|
end
|
388
402
|
|
@@ -393,7 +407,7 @@ module Couchbase
|
|
393
407
|
|
394
408
|
# @api private
|
395
409
|
def first_error
|
396
|
-
encoded[first_error_index].error
|
410
|
+
encoded[first_error_index].error unless success?
|
397
411
|
end
|
398
412
|
|
399
413
|
# @return [Array<SubDocumentField>] holds the encoded subdocument responses
|
@@ -410,13 +424,12 @@ module Couchbase
|
|
410
424
|
private
|
411
425
|
|
412
426
|
def get_field_at_index(index)
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
end
|
427
|
+
raise Error::PathInvalid, "Index is out of bounds: #{index}" unless index >= 0 && index < encoded.size
|
428
|
+
|
429
|
+
field = encoded[index]
|
430
|
+
raise field.error unless field.success?
|
431
|
+
|
432
|
+
field
|
420
433
|
end
|
421
434
|
end
|
422
435
|
|
@@ -458,7 +471,8 @@ module Couchbase
|
|
458
471
|
#
|
459
472
|
# [+:success+] Indicates a successful response in general.
|
460
473
|
# [+:path_not_found+] The provided path does not exist in the document
|
461
|
-
# [+:path_mismatch+] One of path components treats a non-dictionary as a dictionary, or a non-array as an array, or value the path
|
474
|
+
# [+:path_mismatch+] One of path components treats a non-dictionary as a dictionary, or a non-array as an array, or value the path
|
475
|
+
# points to is not a number
|
462
476
|
# [+:path_invalid+] The path's syntax was incorrect
|
463
477
|
# [+:path_too_big+] The path provided is too large: either the string is too long, or it contains too many components
|
464
478
|
# [+:value_cannot_insert+] The value provided will invalidate the JSON if inserted
|
@@ -63,14 +63,14 @@ module Couchbase
|
|
63
63
|
# @return [Integer] returns the number of elements in the list.
|
64
64
|
def length
|
65
65
|
result = @collection.lookup_in(@id, [
|
66
|
-
|
67
|
-
|
66
|
+
LookupInSpec.count(""),
|
67
|
+
], @options.lookup_in_options)
|
68
68
|
result.content(0)
|
69
69
|
rescue Error::DocumentNotFound
|
70
70
|
0
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
alias size length
|
74
74
|
|
75
75
|
# @return [Boolean] returns true if list is empty
|
76
76
|
def empty?
|
@@ -84,12 +84,12 @@ module Couchbase
|
|
84
84
|
# @return [CouchbaseList]
|
85
85
|
def push(*obj)
|
86
86
|
@collection.mutate_in(@id, [
|
87
|
-
|
88
|
-
|
87
|
+
MutateInSpec.array_append("", obj),
|
88
|
+
], @options.mutate_in_options)
|
89
89
|
self
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
alias append push
|
93
93
|
|
94
94
|
# Prepends objects to the front of the list, moving other elements upwards
|
95
95
|
#
|
@@ -97,12 +97,12 @@ module Couchbase
|
|
97
97
|
# @return [CouchbaseList]
|
98
98
|
def unshift(*obj)
|
99
99
|
@collection.mutate_in(@id, [
|
100
|
-
|
101
|
-
|
100
|
+
MutateInSpec.array_prepend("", obj),
|
101
|
+
], @options.mutate_in_options)
|
102
102
|
self
|
103
103
|
end
|
104
104
|
|
105
|
-
|
105
|
+
alias prepend unshift
|
106
106
|
|
107
107
|
# Inserts the given values before the element with the given +index+.
|
108
108
|
#
|
@@ -111,8 +111,8 @@ module Couchbase
|
|
111
111
|
# @return [CouchbaseList]
|
112
112
|
def insert(index, *obj)
|
113
113
|
@collection.mutate_in(@id, [
|
114
|
-
|
115
|
-
|
114
|
+
MutateInSpec.array_insert("[#{index.to_i}]", obj),
|
115
|
+
])
|
116
116
|
self
|
117
117
|
end
|
118
118
|
|
@@ -122,14 +122,14 @@ module Couchbase
|
|
122
122
|
# @return [Object, nil]
|
123
123
|
def at(index)
|
124
124
|
result = @collection.lookup_in(@id, [
|
125
|
-
|
126
|
-
|
125
|
+
LookupInSpec.get("[#{index.to_i}]"),
|
126
|
+
], @options.lookup_in_options)
|
127
127
|
result.exists?(0) ? result.content(0) : nil
|
128
128
|
rescue Error::DocumentNotFound
|
129
129
|
nil
|
130
130
|
end
|
131
131
|
|
132
|
-
|
132
|
+
alias [] at
|
133
133
|
|
134
134
|
# Deletes the element at the specified +index+, returning that element, or nil
|
135
135
|
#
|
@@ -137,8 +137,8 @@ module Couchbase
|
|
137
137
|
# @return [CouchbaseList]
|
138
138
|
def delete_at(index)
|
139
139
|
@collection.mutate_in(@id, [
|
140
|
-
|
141
|
-
|
140
|
+
MutateInSpec.remove("[#{index.to_i}]"),
|
141
|
+
])
|
142
142
|
self
|
143
143
|
rescue Error::DocumentNotFound
|
144
144
|
self
|
@@ -63,14 +63,14 @@ module Couchbase
|
|
63
63
|
# @return [Integer] returns the number of elements in the map.
|
64
64
|
def length
|
65
65
|
result = @collection.lookup_in(@id, [
|
66
|
-
|
67
|
-
|
66
|
+
LookupInSpec.count(""),
|
67
|
+
], @options.lookup_in_options)
|
68
68
|
result.content(0)
|
69
69
|
rescue Error::DocumentNotFound
|
70
70
|
0
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
alias size length
|
74
74
|
|
75
75
|
# @return [Boolean] returns true if map is empty
|
76
76
|
def empty?
|
@@ -110,12 +110,13 @@ module Couchbase
|
|
110
110
|
# @return [Object]
|
111
111
|
def fetch(key, *rest)
|
112
112
|
result = @collection.lookup_in(@id, [
|
113
|
-
|
114
|
-
|
113
|
+
LookupInSpec.get(key),
|
114
|
+
], @options.lookup_in_options)
|
115
115
|
result.content(0)
|
116
116
|
rescue Error::DocumentNotFound, Error::PathNotFound
|
117
117
|
return yield if block_given?
|
118
|
-
return rest.first
|
118
|
+
return rest.first unless rest.empty?
|
119
|
+
|
119
120
|
raise KeyError, "key not found: #{key}"
|
120
121
|
end
|
121
122
|
|
@@ -135,12 +136,11 @@ module Couchbase
|
|
135
136
|
# @param [String] key
|
136
137
|
# @param [Object] value
|
137
138
|
#
|
138
|
-
# @return
|
139
|
+
# @return [void]
|
139
140
|
def []=(key, value)
|
140
141
|
@collection.mutate_in(@id, [
|
141
|
-
|
142
|
-
|
143
|
-
value
|
142
|
+
MutateInSpec.upsert(key, value),
|
143
|
+
], @options.mutate_in_options)
|
144
144
|
end
|
145
145
|
|
146
146
|
# Deletes the key-value pair from the map.
|
@@ -150,8 +150,8 @@ module Couchbase
|
|
150
150
|
# @return void
|
151
151
|
def delete(key)
|
152
152
|
@collection.mutate_in(@id, [
|
153
|
-
|
154
|
-
|
153
|
+
MutateInSpec.remove(key),
|
154
|
+
])
|
155
155
|
rescue Error::DocumentNotFound, Error::PathNotFound
|
156
156
|
nil
|
157
157
|
end
|
@@ -162,28 +162,28 @@ module Couchbase
|
|
162
162
|
# @return [Boolean]
|
163
163
|
def key?(key)
|
164
164
|
result = @collection.lookup_in(@id, [
|
165
|
-
|
166
|
-
|
165
|
+
LookupInSpec.exists(key),
|
166
|
+
], @options.lookup_in_options)
|
167
167
|
result.exists?(0)
|
168
168
|
rescue Error::DocumentNotFound, Error::PathNotFound
|
169
169
|
false
|
170
170
|
end
|
171
171
|
|
172
|
-
|
173
|
-
|
172
|
+
alias member? key?
|
173
|
+
alias include? key?
|
174
174
|
|
175
175
|
# Returns a new array populated with the keys from the map.
|
176
176
|
#
|
177
177
|
# @return [Array]
|
178
178
|
def keys
|
179
|
-
map {|key, _value| key}
|
179
|
+
map { |key, _value| key }
|
180
180
|
end
|
181
181
|
|
182
182
|
# Returns a new array populated with the values from the map.
|
183
183
|
#
|
184
184
|
# @return [Array]
|
185
185
|
def values
|
186
|
-
map {|_key, value| value}
|
186
|
+
map { |_key, value| value }
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|