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/examples/analytics.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Copyright 2020 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase"
|
16
|
+
|
17
|
+
include Couchbase # rubocop:disable Style/MixinUsage for brevity
|
4
18
|
|
5
19
|
options = Cluster::ClusterOptions.new
|
6
20
|
options.authenticate("Administrator", "password")
|
7
21
|
cluster = Cluster.connect("couchbase://localhost", options)
|
8
22
|
|
9
|
-
|
10
23
|
bucket_name = "tiny_social"
|
11
24
|
dataverse_name = "TinySocial"
|
12
25
|
|
@@ -31,116 +44,116 @@ collection = cluster.bucket(bucket_name).default_collection
|
|
31
44
|
|
32
45
|
# Documents for GleambookUsers dataset
|
33
46
|
[
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
47
|
+
{
|
48
|
+
"id" => 1,
|
49
|
+
"alias" => "Margarita",
|
50
|
+
"name" => "MargaritaStoddard",
|
51
|
+
"nickname" => "Mags",
|
52
|
+
"userSince" => "2012-08-20T10:10:00",
|
53
|
+
"friendIds" => [2, 3, 6, 10],
|
54
|
+
"employment" => [
|
55
|
+
{
|
56
|
+
"organizationName" => "Codetechno",
|
57
|
+
"start-date" => "2006-08-06",
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"organizationName" => "geomedia",
|
61
|
+
"start-date" => "2010-06-17",
|
62
|
+
"end-date" => "2010-01-26",
|
63
|
+
},
|
64
|
+
],
|
65
|
+
"gender" => "F",
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"id" => 2,
|
69
|
+
"alias" => "Isbel",
|
70
|
+
"name" => "IsbelDull",
|
71
|
+
"nickname" => "Izzy",
|
72
|
+
"userSince" => "2011-01-22T10:10:00",
|
73
|
+
"friendIds" => [1, 4],
|
74
|
+
"employment" => [
|
75
|
+
{
|
76
|
+
"organizationName" => "Hexviafind",
|
77
|
+
"startDate" => "2010-04-27",
|
78
|
+
},
|
79
|
+
],
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"id" => 3,
|
83
|
+
"alias" => "Emory",
|
84
|
+
"name" => "EmoryUnk",
|
85
|
+
"userSince" => "2012-07-10T10:10:00",
|
86
|
+
"friendIds" => [1, 5, 8, 9],
|
87
|
+
"employment" => [
|
88
|
+
{
|
89
|
+
"organizationName" => "geomedia",
|
90
|
+
"startDate" => "2010-06-17",
|
91
|
+
"endDate" => "2010-01-26",
|
92
|
+
},
|
93
|
+
],
|
94
|
+
},
|
82
95
|
].each do |document|
|
83
|
-
collection.upsert("user:#{document[
|
96
|
+
collection.upsert("user:#{document['id']}",
|
84
97
|
document.merge({"type" => "user"}))
|
85
98
|
end
|
86
99
|
|
87
100
|
# Documents for GleambookMessages dataset
|
88
101
|
[
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
102
|
+
{
|
103
|
+
"messageId" => 2,
|
104
|
+
"authorId" => 1,
|
105
|
+
"inResponseTo" => 4,
|
106
|
+
"senderLocation" => [41.66, 80.87],
|
107
|
+
"message" => " dislike x-phone its touch-screen is horrible",
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"messageId" => 3,
|
111
|
+
"authorId" => 2,
|
112
|
+
"inResponseTo" => 4,
|
113
|
+
"senderLocation" => [48.09, 81.01],
|
114
|
+
"message" => " like product-y the plan is amazing",
|
115
|
+
},
|
116
|
+
{
|
117
|
+
"messageId" => 4,
|
118
|
+
"authorId" => 1,
|
119
|
+
"inResponseTo" => 2,
|
120
|
+
"senderLocation" => [37.73, 97.04],
|
121
|
+
"message" => " can't stand acast the network is horrible:(",
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"messageId" => 6,
|
125
|
+
"authorId" => 2,
|
126
|
+
"inResponseTo" => 1,
|
127
|
+
"senderLocation" => [31.5, 75.56],
|
128
|
+
"message" => " like product-z its platform is mind-blowing",
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"messageId" => 8,
|
132
|
+
"authorId" => 1,
|
133
|
+
"inResponseTo" => 11,
|
134
|
+
"senderLocation" => [40.33, 80.87],
|
135
|
+
"message" => " like ccast the 3G is awesome:)",
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"messageId" => 10,
|
139
|
+
"authorId" => 1,
|
140
|
+
"inResponseTo" => 12,
|
141
|
+
"senderLocation" => [42.5, 70.01],
|
142
|
+
"message" => " can't stand product-w the touch-screen is terrible",
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"messageId" => 11,
|
146
|
+
"authorId" => 1,
|
147
|
+
"inResponseTo" => 1,
|
148
|
+
"senderLocation" => [38.97, 77.49],
|
149
|
+
"message" => " can't stand acast its plan is terrible",
|
150
|
+
},
|
138
151
|
].each do |document|
|
139
|
-
collection.upsert("message:#{document[
|
152
|
+
collection.upsert("message:#{document['messageId']}",
|
140
153
|
document.merge({"type" => "message"}))
|
141
154
|
end
|
142
155
|
|
143
|
-
if cluster.analytics_indexes.get_all_datasets.any? {|ds| ds.dataverse_name == dataverse_name}
|
156
|
+
if cluster.analytics_indexes.get_all_datasets.any? { |ds| ds.dataverse_name == dataverse_name }
|
144
157
|
# there are datasets on our dataverse, drop everything and re-create
|
145
158
|
options = Management::AnalyticsIndexManager::DisconnectLinkOptions.new
|
146
159
|
options.dataverse_name = dataverse_name
|
@@ -166,9 +179,11 @@ cluster.analytics_indexes.connect_link(options)
|
|
166
179
|
sleep(1)
|
167
180
|
|
168
181
|
puts "---- inner join"
|
169
|
-
res = cluster.analytics_query(
|
182
|
+
res = cluster.analytics_query(
|
183
|
+
"SELECT * FROM #{dataverse_name}.GleambookUsers u, #{dataverse_name}.GleambookMessages m WHERE m.authorId = u.id"
|
184
|
+
)
|
170
185
|
res.rows.each do |row|
|
171
|
-
puts "#{row[
|
186
|
+
puts "#{row['u']['name']}: #{row['m']['message'].inspect}"
|
172
187
|
end
|
173
188
|
|
174
189
|
# The query language supports SQL's notion of left outer join.
|
@@ -180,7 +195,7 @@ res = cluster.analytics_query("
|
|
180
195
|
LEFT OUTER JOIN GleambookMessages m ON m.authorId = u.id
|
181
196
|
")
|
182
197
|
res.rows.each do |row|
|
183
|
-
puts "#{row[
|
198
|
+
puts "#{row['uname']}: #{row['message'].inspect}"
|
184
199
|
end
|
185
200
|
|
186
201
|
# Named parameters
|
@@ -215,7 +230,7 @@ FROM GleambookUsers AS user
|
|
215
230
|
WHERE len(user.friendIds) > $1
|
216
231
|
", options)
|
217
232
|
res.rows.each do |row|
|
218
|
-
puts "#{row[
|
233
|
+
puts "#{row['name']}: #{row['friendIds'].size}"
|
219
234
|
end
|
220
235
|
|
221
236
|
# More query examples at https://docs.couchbase.com/server/current/analytics/3_query.html
|
data/examples/auth.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright 2020 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase"
|
16
|
+
include Couchbase # rubocop:disable Style/MixinUsage for brevity
|
17
|
+
|
18
|
+
options = Cluster::ClusterOptions.new
|
19
|
+
# initializes {PasswordAuthenticator} internally
|
20
|
+
options.authenticate("Administrator", "password")
|
21
|
+
Cluster.connect("couchbase://localhost", options)
|
22
|
+
|
23
|
+
# the same as above, but more explicit
|
24
|
+
options.authenticator = PasswordAuthenticator.new("Administrator", "password")
|
25
|
+
Cluster.connect("couchbase://localhost", options)
|
26
|
+
|
27
|
+
# shorter version, more useful for interactive sessions
|
28
|
+
Cluster.connect("couchbase://localhost", "Administrator", "password")
|
29
|
+
|
30
|
+
# authentication with TLS client certificate
|
31
|
+
# @see https://docs.couchbase.com/server/current/manage/manage-security/configure-client-certificates.html
|
32
|
+
options.authenticator = CertificateAuthenticator.new("/tmp/certificate.pem", "/tmp/private.key")
|
33
|
+
Cluster.connect("couchbases://localhost?trust_certificate=/tmp/ca.pem", options)
|
data/examples/crud.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Copyright 2020 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase"
|
16
|
+
include Couchbase # rubocop:disable Style/MixinUsage for brevity
|
3
17
|
|
4
18
|
options = Cluster::ClusterOptions.new
|
5
19
|
options.authenticate("Administrator", "password")
|
@@ -1,10 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Copyright 2020 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase"
|
16
|
+
include Couchbase # rubocop:disable Style/MixinUsage for brevity
|
3
17
|
|
4
18
|
def measure(msg)
|
5
19
|
start = Time.now
|
6
20
|
yield
|
7
|
-
printf "
|
21
|
+
printf "%<msg>s in %<elapsed>.2f seconds\n", msg: msg, elapsed: Time.now - start
|
8
22
|
end
|
9
23
|
|
10
24
|
options = Cluster::ClusterOptions.new
|
@@ -47,7 +61,7 @@ manager.create_index("breweries_loc_idx", "beers", {"geo.lon" => "double", "geo.
|
|
47
61
|
|
48
62
|
puts "---- Indexes currently defined on the cluster:"
|
49
63
|
manager.get_all_indexes.each_with_index do |index, i|
|
50
|
-
puts "#{i}. #{index.dataverse_name}.#{index.dataset_name}.#{index.name} #{
|
64
|
+
puts "#{i}. #{index.dataverse_name}.#{index.dataset_name}.#{index.name} #{'(primary)' if index.primary?}"
|
51
65
|
end
|
52
66
|
|
53
67
|
# Drops one of the indexes
|
@@ -1,10 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Copyright 2020 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase"
|
16
|
+
include Couchbase # rubocop:disable Style/MixinUsage for brevity
|
3
17
|
|
4
18
|
def measure(msg)
|
5
19
|
start = Time.now
|
6
20
|
yield
|
7
|
-
printf "
|
21
|
+
printf "%<msg>s in %<elapsed>.2f seconds\n", msg: msg, elapsed: Time.now - start
|
8
22
|
end
|
9
23
|
|
10
24
|
options = Cluster::ClusterOptions.new
|
@@ -1,10 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Copyright 2020 Couchbase, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "couchbase"
|
16
|
+
include Couchbase # rubocop:disable Style/MixinUsage for brevity
|
3
17
|
|
4
18
|
def measure(msg)
|
5
19
|
start = Time.now
|
6
20
|
yield
|
7
|
-
printf "
|
21
|
+
printf "%<msg>s in %<elapsed>.2f seconds\n", msg: msg, elapsed: Time.now - start
|
8
22
|
end
|
9
23
|
|
10
24
|
bucket_name = "travel-sample"
|
@@ -15,7 +29,6 @@ options.authenticate("Administrator", "password")
|
|
15
29
|
cluster = Cluster.connect("couchbase://localhost", options)
|
16
30
|
bucket = cluster.bucket(bucket_name)
|
17
31
|
|
18
|
-
|
19
32
|
scopes = bucket.collections.get_all_scopes
|
20
33
|
puts "There are #{scopes.size} on the bucket \"#{bucket_name}\""
|
21
34
|
|
@@ -26,7 +39,7 @@ scopes.each do |scope|
|
|
26
39
|
end
|
27
40
|
end
|
28
41
|
|
29
|
-
if scopes.any? {|scope| scope.name == scope_name }
|
42
|
+
if scopes.any? { |scope| scope.name == scope_name }
|
30
43
|
measure("Scope \"#{scope_name}\" has been removed") { bucket.collections.drop_scope(scope_name) }
|
31
44
|
end
|
32
45
|
measure("Scope \"#{scope_name}\" has been created") { bucket.collections.create_scope(scope_name) }
|
@@ -43,8 +56,8 @@ end
|
|
43
56
|
|
44
57
|
scope = bucket.collections.get_scope(scope_name)
|
45
58
|
puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
|
46
|
-
scope.collections.each do |
|
47
|
-
puts " * \"#{
|
59
|
+
scope.collections.each do |c|
|
60
|
+
puts " * \"#{c.name}\""
|
48
61
|
end
|
49
62
|
|
50
63
|
measure("Collection \"#{collection.name}\" on scope \"#{collection.scope_name}\" has been dropped") do
|
@@ -53,6 +66,6 @@ end
|
|
53
66
|
|
54
67
|
scope = bucket.collections.get_scope(scope_name)
|
55
68
|
puts "Scope \"#{scope_name}\" has #{scope.collections.size} collections"
|
56
|
-
scope.collections.each do |
|
57
|
-
puts " * \"#{
|
69
|
+
scope.collections.each do |c|
|
70
|
+
puts " * \"#{c.name}\""
|
58
71
|
end
|