couchbase 3.2.0 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -18
- package/binding.gyp +88 -85
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +99 -14
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/CMakeLists.txt +4 -4
- package/deps/lcb/example/libuvdirect/main.c +39 -12
- package/deps/lcb/example/minimal/durability.cc +149 -0
- package/deps/lcb/example/minimal/query.c +11 -9
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
- package/deps/lcb/include/libcouchbase/error.h +2 -0
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +347 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
- package/deps/lcb/src/bootstrap.cc +6 -3
- package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
- package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
- package/deps/lcb/src/capi/cmd_counter.hh +23 -0
- package/deps/lcb/src/capi/cmd_exists.hh +24 -1
- package/deps/lcb/src/capi/cmd_get.hh +22 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
- package/deps/lcb/src/capi/cmd_http.hh +7 -0
- package/deps/lcb/src/capi/cmd_query.cc +11 -1
- package/deps/lcb/src/capi/cmd_query.hh +31 -0
- package/deps/lcb/src/capi/cmd_remove.hh +23 -0
- package/deps/lcb/src/capi/cmd_search.cc +6 -0
- package/deps/lcb/src/capi/cmd_search.hh +23 -0
- package/deps/lcb/src/capi/cmd_store.hh +33 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
- package/deps/lcb/src/capi/cmd_touch.hh +23 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
- package/deps/lcb/src/cntl.cc +45 -11
- package/deps/lcb/src/crypto.cc +2 -2
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/hostlist.h +2 -2
- package/deps/lcb/src/http/http-priv.h +2 -2
- package/deps/lcb/src/http/http.cc +5 -2
- package/deps/lcb/src/instance.cc +20 -11
- package/deps/lcb/src/internal.h +9 -0
- package/deps/lcb/src/lcbio/connect.cc +14 -2
- package/deps/lcb/src/lcbio/connect.h +2 -2
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/lcbio/ioutils.cc +9 -10
- package/deps/lcb/src/lcbio/manager.cc +1 -1
- package/deps/lcb/src/mcserver/mcserver.cc +9 -6
- package/deps/lcb/src/mcserver/negotiate.cc +39 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/query_handle.cc +41 -19
- package/deps/lcb/src/n1ql/query_handle.hh +28 -1
- package/deps/lcb/src/operations/counter.cc +18 -5
- package/deps/lcb/src/operations/exists.cc +25 -4
- package/deps/lcb/src/operations/get.cc +39 -19
- package/deps/lcb/src/operations/get_replica.cc +28 -8
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/ping.cc +8 -8
- package/deps/lcb/src/operations/pktfwd.cc +2 -1
- package/deps/lcb/src/operations/remove.cc +39 -22
- package/deps/lcb/src/operations/store.cc +18 -5
- package/deps/lcb/src/operations/subdoc.cc +18 -6
- package/deps/lcb/src/operations/touch.cc +34 -16
- package/deps/lcb/src/operations/unlock.cc +24 -5
- package/deps/lcb/src/packetutils.h +3 -2
- package/deps/lcb/src/retryq.cc +24 -5
- package/deps/lcb/src/search/search.cc +1 -0
- package/deps/lcb/src/search/search_handle.cc +30 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/settings.cc +1 -1
- package/deps/lcb/src/ssl/ssl_common.c +6 -7
- package/deps/lcb/src/tracing/span.cc +47 -14
- package/deps/lcb/src/tracing/tracer.cc +11 -2
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +43 -0
- package/deps/lcb/src/utilities.h +53 -0
- package/deps/lcb/src/vbucket/vbucket.c +34 -33
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -0
- package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
- package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +109 -7
- package/deps/lcb/tests/iotests/t_http.cc +9 -4
- package/deps/lcb/tests/iotests/t_lock.cc +18 -0
- package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
- package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +168 -0
- package/deps/lcb/tests/iotests/testutil.h +116 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tests/mocksupport/timeout.c +2 -2
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binding.d.ts +3 -0
- package/dist/bindingutilities.js +4 -0
- package/dist/bucket.js +1 -1
- package/dist/bucketmanager.d.ts +31 -1
- package/dist/bucketmanager.js +194 -186
- package/dist/cluster.d.ts +7 -0
- package/dist/cluster.js +48 -38
- package/dist/collection.js +11 -17
- package/dist/collectionmanager.js +181 -197
- package/dist/connection.d.ts +3 -1
- package/dist/connection.js +27 -16
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +3 -13
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +70 -0
- package/dist/errors.js +96 -2
- package/dist/eventingfunctionmanager.d.ts +804 -0
- package/dist/eventingfunctionmanager.js +993 -0
- package/dist/httpexecutor.d.ts +2 -1
- package/dist/httpexecutor.js +30 -37
- package/dist/queryindexmanager.js +240 -266
- package/dist/scope.js +10 -4
- package/dist/sdspecs.d.ts +1 -1
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +251 -264
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +7 -2
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/addondata.cpp +58 -0
- package/src/addondata.h +40 -0
- package/src/binding.cpp +3 -1
- package/src/cas.h +2 -2
- package/src/connection.cpp +25 -178
- package/src/connection.h +8 -65
- package/src/connection_ops.cpp +57 -34
- package/src/constants.cpp +3 -0
- package/src/instance.cpp +235 -0
- package/src/instance.h +102 -0
- package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
- package/src/logger.cpp +11 -1
- package/src/logger.h +3 -0
- package/src/metrics.cpp +10 -0
- package/src/metrics.h +3 -0
- package/src/mutationtoken.h +2 -2
- package/src/opbuilder.h +13 -15
- package/src/respreader.cpp +1 -0
- package/src/respreader.h +6 -4
- package/src/tracespan.h +11 -11
- package/src/tracing.cpp +11 -0
- package/src/tracing.h +3 -0
- package/src/valueparser.h +5 -0
- package/deps/lcb/example/observe/durability.c +0 -110
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.QueryIndexManager = exports.QueryIndex = void 0;
|
|
13
4
|
const errors_1 = require("./errors");
|
|
@@ -50,56 +41,54 @@ class QueryIndexManager {
|
|
|
50
41
|
get _http() {
|
|
51
42
|
return new httpexecutor_1.HttpExecutor(this._cluster._getClusterConn());
|
|
52
43
|
}
|
|
53
|
-
_createIndex(bucketName, options, callback) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
qs += ', ';
|
|
71
|
-
}
|
|
72
|
-
qs += '`' + options.fields[i] + '`';
|
|
44
|
+
async _createIndex(bucketName, options, callback) {
|
|
45
|
+
let qs = '';
|
|
46
|
+
if (!options.fields) {
|
|
47
|
+
qs += 'CREATE PRIMARY INDEX';
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
qs += 'CREATE INDEX';
|
|
51
|
+
}
|
|
52
|
+
if (options.name) {
|
|
53
|
+
qs += ' `' + options.name + '`';
|
|
54
|
+
}
|
|
55
|
+
qs += ' ON `' + bucketName + '`';
|
|
56
|
+
if (options.fields && options.fields.length > 0) {
|
|
57
|
+
qs += '(';
|
|
58
|
+
for (let i = 0; i < options.fields.length; ++i) {
|
|
59
|
+
if (i > 0) {
|
|
60
|
+
qs += ', ';
|
|
73
61
|
}
|
|
74
|
-
qs += '
|
|
75
|
-
}
|
|
76
|
-
const withOpts = {};
|
|
77
|
-
if (options.deferred) {
|
|
78
|
-
withOpts.defer_build = true;
|
|
79
|
-
}
|
|
80
|
-
if (options.numReplicas) {
|
|
81
|
-
withOpts.num_replica = options.numReplicas;
|
|
62
|
+
qs += '`' + options.fields[i] + '`';
|
|
82
63
|
}
|
|
83
|
-
|
|
84
|
-
|
|
64
|
+
qs += ')';
|
|
65
|
+
}
|
|
66
|
+
const withOpts = {};
|
|
67
|
+
if (options.deferred) {
|
|
68
|
+
withOpts.defer_build = true;
|
|
69
|
+
}
|
|
70
|
+
if (options.numReplicas) {
|
|
71
|
+
withOpts.num_replica = options.numReplicas;
|
|
72
|
+
}
|
|
73
|
+
if (Object.keys(withOpts).length > 0) {
|
|
74
|
+
qs += ' WITH ' + JSON.stringify(withOpts);
|
|
75
|
+
}
|
|
76
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
77
|
+
try {
|
|
78
|
+
await this._cluster.query(qs, {
|
|
79
|
+
parentSpan: options.parentSpan,
|
|
80
|
+
timeout: options.timeout,
|
|
81
|
+
});
|
|
85
82
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
parentSpan: options.parentSpan,
|
|
90
|
-
timeout: options.timeout,
|
|
91
|
-
});
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (options.ignoreIfExists && err instanceof errors_1.IndexExistsError) {
|
|
85
|
+
// swallow the error if the user wants us to
|
|
92
86
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// swallow the error if the user wants us to
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
87
|
+
else {
|
|
88
|
+
throw err;
|
|
100
89
|
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
90
|
+
}
|
|
91
|
+
}, callback);
|
|
103
92
|
}
|
|
104
93
|
/**
|
|
105
94
|
* Creates a new query index.
|
|
@@ -110,25 +99,23 @@ class QueryIndexManager {
|
|
|
110
99
|
* @param options Optional parameters for this operation.
|
|
111
100
|
* @param callback A node-style callback to be invoked after execution.
|
|
112
101
|
*/
|
|
113
|
-
createIndex(bucketName, indexName, fields, options, callback) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, callback);
|
|
131
|
-
});
|
|
102
|
+
async createIndex(bucketName, indexName, fields, options, callback) {
|
|
103
|
+
if (options instanceof Function) {
|
|
104
|
+
callback = arguments[3];
|
|
105
|
+
options = undefined;
|
|
106
|
+
}
|
|
107
|
+
if (!options) {
|
|
108
|
+
options = {};
|
|
109
|
+
}
|
|
110
|
+
return this._createIndex(bucketName, {
|
|
111
|
+
name: indexName,
|
|
112
|
+
fields: fields,
|
|
113
|
+
ignoreIfExists: options.ignoreIfExists,
|
|
114
|
+
numReplicas: options.numReplicas,
|
|
115
|
+
deferred: options.deferred,
|
|
116
|
+
parentSpan: options.parentSpan,
|
|
117
|
+
timeout: options.timeout,
|
|
118
|
+
}, callback);
|
|
132
119
|
}
|
|
133
120
|
/**
|
|
134
121
|
* Creates a new primary query index.
|
|
@@ -137,51 +124,47 @@ class QueryIndexManager {
|
|
|
137
124
|
* @param options Optional parameters for this operation.
|
|
138
125
|
* @param callback A node-style callback to be invoked after execution.
|
|
139
126
|
*/
|
|
140
|
-
createPrimaryIndex(bucketName, options, callback) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
127
|
+
async createPrimaryIndex(bucketName, options, callback) {
|
|
128
|
+
if (options instanceof Function) {
|
|
129
|
+
callback = arguments[1];
|
|
130
|
+
options = undefined;
|
|
131
|
+
}
|
|
132
|
+
if (!options) {
|
|
133
|
+
options = {};
|
|
134
|
+
}
|
|
135
|
+
return this._createIndex(bucketName, {
|
|
136
|
+
name: options.name,
|
|
137
|
+
ignoreIfExists: options.ignoreIfExists,
|
|
138
|
+
deferred: options.deferred,
|
|
139
|
+
parentSpan: options.parentSpan,
|
|
140
|
+
timeout: options.timeout,
|
|
141
|
+
}, callback);
|
|
142
|
+
}
|
|
143
|
+
async _dropIndex(bucketName, options, callback) {
|
|
144
|
+
const timeout = options.timeout;
|
|
145
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
146
|
+
let qs = '';
|
|
147
|
+
if (!options.name) {
|
|
148
|
+
qs += 'DROP PRIMARY INDEX `' + bucketName + '`';
|
|
145
149
|
}
|
|
146
|
-
|
|
147
|
-
options
|
|
150
|
+
else {
|
|
151
|
+
qs += 'DROP INDEX `' + bucketName + '`.`' + options.name + '`';
|
|
148
152
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
_dropIndex(bucketName, options, callback) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
const timeout = options.timeout;
|
|
161
|
-
return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
let qs = '';
|
|
163
|
-
if (!options.name) {
|
|
164
|
-
qs += 'DROP PRIMARY INDEX `' + bucketName + '`';
|
|
153
|
+
try {
|
|
154
|
+
await this._cluster.query(qs, {
|
|
155
|
+
parentSpan: options.parentSpan,
|
|
156
|
+
timeout: timeout,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
if (options.ignoreIfNotExists && err instanceof errors_1.IndexNotFoundError) {
|
|
161
|
+
// swallow the error if the user wants us to
|
|
165
162
|
}
|
|
166
163
|
else {
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
yield this._cluster.query(qs, {
|
|
171
|
-
parentSpan: options.parentSpan,
|
|
172
|
-
timeout: timeout,
|
|
173
|
-
});
|
|
164
|
+
throw err;
|
|
174
165
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// swallow the error if the user wants us to
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
throw err;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}), callback);
|
|
184
|
-
});
|
|
166
|
+
}
|
|
167
|
+
}, callback);
|
|
185
168
|
}
|
|
186
169
|
/**
|
|
187
170
|
* Drops an existing query index.
|
|
@@ -191,22 +174,20 @@ class QueryIndexManager {
|
|
|
191
174
|
* @param options Optional parameters for this operation.
|
|
192
175
|
* @param callback A node-style callback to be invoked after execution.
|
|
193
176
|
*/
|
|
194
|
-
dropIndex(bucketName, indexName, options, callback) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}, callback);
|
|
209
|
-
});
|
|
177
|
+
async dropIndex(bucketName, indexName, options, callback) {
|
|
178
|
+
if (options instanceof Function) {
|
|
179
|
+
callback = arguments[2];
|
|
180
|
+
options = undefined;
|
|
181
|
+
}
|
|
182
|
+
if (!options) {
|
|
183
|
+
options = {};
|
|
184
|
+
}
|
|
185
|
+
return this._dropIndex(bucketName, {
|
|
186
|
+
name: indexName,
|
|
187
|
+
ignoreIfNotExists: options.ignoreIfNotExists,
|
|
188
|
+
parentSpan: options.parentSpan,
|
|
189
|
+
timeout: options.timeout,
|
|
190
|
+
}, callback);
|
|
210
191
|
}
|
|
211
192
|
/**
|
|
212
193
|
* Drops an existing primary index.
|
|
@@ -215,22 +196,20 @@ class QueryIndexManager {
|
|
|
215
196
|
* @param options Optional parameters for this operation.
|
|
216
197
|
* @param callback A node-style callback to be invoked after execution.
|
|
217
198
|
*/
|
|
218
|
-
dropPrimaryIndex(bucketName, options, callback) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}, callback);
|
|
233
|
-
});
|
|
199
|
+
async dropPrimaryIndex(bucketName, options, callback) {
|
|
200
|
+
if (options instanceof Function) {
|
|
201
|
+
callback = arguments[1];
|
|
202
|
+
options = undefined;
|
|
203
|
+
}
|
|
204
|
+
if (!options) {
|
|
205
|
+
options = {};
|
|
206
|
+
}
|
|
207
|
+
return this._dropIndex(bucketName, {
|
|
208
|
+
name: options.name,
|
|
209
|
+
ignoreIfNotExists: options.ignoreIfNotExists,
|
|
210
|
+
parentSpan: options.parentSpan,
|
|
211
|
+
timeout: options.timeout,
|
|
212
|
+
}, callback);
|
|
234
213
|
}
|
|
235
214
|
/**
|
|
236
215
|
* Returns a list of indexes for a specific bucket.
|
|
@@ -239,39 +218,38 @@ class QueryIndexManager {
|
|
|
239
218
|
* @param options Optional parameters for this operation.
|
|
240
219
|
* @param callback A node-style callback to be invoked after execution.
|
|
241
220
|
*/
|
|
242
|
-
getAllIndexes(bucketName, options, callback) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
221
|
+
async getAllIndexes(bucketName, options, callback) {
|
|
222
|
+
if (options instanceof Function) {
|
|
223
|
+
callback = arguments[1];
|
|
224
|
+
options = undefined;
|
|
225
|
+
}
|
|
226
|
+
if (!options) {
|
|
227
|
+
options = {};
|
|
228
|
+
}
|
|
229
|
+
const qs = `SELECT idx.* FROM system:indexes AS idx
|
|
230
|
+
WHERE (
|
|
231
|
+
(\`bucket_id\` IS MISSING AND \`keyspace_id\`="${bucketName}")
|
|
232
|
+
OR \`bucket_id\`="${bucketName}"
|
|
233
|
+
) AND \`using\`="gsi" ORDER BY is_primary DESC, name ASC`;
|
|
234
|
+
const parentSpan = options.parentSpan;
|
|
235
|
+
const timeout = options.timeout;
|
|
236
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
237
|
+
const res = await this._cluster.query(qs, {
|
|
238
|
+
parentSpan: parentSpan,
|
|
239
|
+
timeout: timeout,
|
|
240
|
+
});
|
|
241
|
+
const indexes = res.rows.map((row) => new QueryIndex({
|
|
242
|
+
name: row.name,
|
|
243
|
+
isPrimary: row.is_primary,
|
|
244
|
+
type: row.using,
|
|
245
|
+
state: row.state,
|
|
246
|
+
keyspace: row.keyspace_id,
|
|
247
|
+
indexKey: row.index_key,
|
|
248
|
+
condition: row.condition,
|
|
249
|
+
partition: row.partition,
|
|
250
|
+
}));
|
|
251
|
+
return indexes;
|
|
252
|
+
}, callback);
|
|
275
253
|
}
|
|
276
254
|
/**
|
|
277
255
|
* Starts building any indexes which were previously created with deferred=true.
|
|
@@ -280,49 +258,47 @@ class QueryIndexManager {
|
|
|
280
258
|
* @param options Optional parameters for this operation.
|
|
281
259
|
* @param callback A node-style callback to be invoked after execution.
|
|
282
260
|
*/
|
|
283
|
-
buildDeferredIndexes(bucketName, options, callback) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
261
|
+
async buildDeferredIndexes(bucketName, options, callback) {
|
|
262
|
+
if (options instanceof Function) {
|
|
263
|
+
callback = arguments[1];
|
|
264
|
+
options = undefined;
|
|
265
|
+
}
|
|
266
|
+
if (!options) {
|
|
267
|
+
options = {};
|
|
268
|
+
}
|
|
269
|
+
const parentSpan = options.parentSpan;
|
|
270
|
+
const timeout = options.timeout;
|
|
271
|
+
const timer = new utilities_1.CompoundTimeout(timeout);
|
|
272
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
273
|
+
const indexes = await this.getAllIndexes(bucketName, {
|
|
274
|
+
parentSpan: parentSpan,
|
|
275
|
+
timeout: timer.left(),
|
|
276
|
+
});
|
|
277
|
+
// Filter out the index names that need to be built
|
|
278
|
+
const deferredList = indexes
|
|
279
|
+
.filter((index) => index.state === 'deferred' || index.state === 'pending')
|
|
280
|
+
.map((index) => index.name);
|
|
281
|
+
// If there are no deferred indexes, we have nothing to do.
|
|
282
|
+
if (deferredList.length === 0) {
|
|
283
|
+
return [];
|
|
291
284
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
timeout: timer.left(),
|
|
299
|
-
});
|
|
300
|
-
// Filter out the index names that need to be built
|
|
301
|
-
const deferredList = indexes
|
|
302
|
-
.filter((index) => index.state === 'deferred' || index.state === 'pending')
|
|
303
|
-
.map((index) => index.name);
|
|
304
|
-
// If there are no deferred indexes, we have nothing to do.
|
|
305
|
-
if (deferredList.length === 0) {
|
|
306
|
-
return [];
|
|
307
|
-
}
|
|
308
|
-
let qs = '';
|
|
309
|
-
qs += 'BUILD INDEX ON `' + bucketName + '` ';
|
|
310
|
-
qs += '(';
|
|
311
|
-
for (let j = 0; j < deferredList.length; ++j) {
|
|
312
|
-
if (j > 0) {
|
|
313
|
-
qs += ', ';
|
|
314
|
-
}
|
|
315
|
-
qs += '`' + deferredList[j] + '`';
|
|
285
|
+
let qs = '';
|
|
286
|
+
qs += 'BUILD INDEX ON `' + bucketName + '` ';
|
|
287
|
+
qs += '(';
|
|
288
|
+
for (let j = 0; j < deferredList.length; ++j) {
|
|
289
|
+
if (j > 0) {
|
|
290
|
+
qs += ', ';
|
|
316
291
|
}
|
|
317
|
-
qs += '
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
292
|
+
qs += '`' + deferredList[j] + '`';
|
|
293
|
+
}
|
|
294
|
+
qs += ')';
|
|
295
|
+
// Run our deferred build query
|
|
296
|
+
await this._cluster.query(qs, {
|
|
297
|
+
timeout: timer.left(),
|
|
298
|
+
});
|
|
299
|
+
// Return the list of indices that we built
|
|
300
|
+
return deferredList;
|
|
301
|
+
}, callback);
|
|
326
302
|
}
|
|
327
303
|
/**
|
|
328
304
|
* Waits for a number of indexes to finish creation and be ready to use.
|
|
@@ -333,54 +309,52 @@ class QueryIndexManager {
|
|
|
333
309
|
* @param options Optional parameters for this operation.
|
|
334
310
|
* @param callback A node-style callback to be invoked after execution.
|
|
335
311
|
*/
|
|
336
|
-
watchIndexes(bucketName, indexNames, timeout, options, callback) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
// Add 500 to our interval to a max of 1000
|
|
370
|
-
curInterval = Math.min(curInterval, curInterval + 500);
|
|
371
|
-
// Make sure we don't go past our user-specified duration
|
|
372
|
-
const userTimeLeft = timer.left();
|
|
373
|
-
if (userTimeLeft !== undefined) {
|
|
374
|
-
curInterval = Math.min(curInterval, userTimeLeft);
|
|
375
|
-
}
|
|
376
|
-
if (curInterval <= 0) {
|
|
377
|
-
throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
|
|
378
|
-
}
|
|
379
|
-
// Wait until curInterval expires
|
|
380
|
-
yield new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
|
|
312
|
+
async watchIndexes(bucketName, indexNames, timeout, options, callback) {
|
|
313
|
+
if (options instanceof Function) {
|
|
314
|
+
callback = arguments[3];
|
|
315
|
+
options = undefined;
|
|
316
|
+
}
|
|
317
|
+
if (!options) {
|
|
318
|
+
options = {};
|
|
319
|
+
}
|
|
320
|
+
if (options.watchPrimary) {
|
|
321
|
+
indexNames = [...indexNames, '#primary'];
|
|
322
|
+
}
|
|
323
|
+
const parentSpan = options.parentSpan;
|
|
324
|
+
const timer = new utilities_1.CompoundTimeout(timeout);
|
|
325
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
326
|
+
let curInterval = 50;
|
|
327
|
+
for (;;) {
|
|
328
|
+
// Get all the indexes that are currently registered
|
|
329
|
+
const foundIdxs = await this.getAllIndexes(bucketName, {
|
|
330
|
+
parentSpan: parentSpan,
|
|
331
|
+
timeout: timer.left(),
|
|
332
|
+
});
|
|
333
|
+
const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
|
|
334
|
+
const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
|
|
335
|
+
// Check if all the indexes we want are online
|
|
336
|
+
let allOnline = true;
|
|
337
|
+
indexNames.forEach((indexName) => {
|
|
338
|
+
allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
|
|
339
|
+
});
|
|
340
|
+
// If all the indexes are online, we've succeeded
|
|
341
|
+
if (allOnline) {
|
|
342
|
+
break;
|
|
381
343
|
}
|
|
382
|
-
|
|
383
|
-
|
|
344
|
+
// Add 500 to our interval to a max of 1000
|
|
345
|
+
curInterval = Math.min(1000, curInterval + 500);
|
|
346
|
+
// Make sure we don't go past our user-specified duration
|
|
347
|
+
const userTimeLeft = timer.left();
|
|
348
|
+
if (userTimeLeft !== undefined) {
|
|
349
|
+
curInterval = Math.min(curInterval, userTimeLeft);
|
|
350
|
+
}
|
|
351
|
+
if (curInterval <= 0) {
|
|
352
|
+
throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
|
|
353
|
+
}
|
|
354
|
+
// Wait until curInterval expires
|
|
355
|
+
await new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
|
|
356
|
+
}
|
|
357
|
+
}, callback);
|
|
384
358
|
}
|
|
385
359
|
}
|
|
386
360
|
exports.QueryIndexManager = QueryIndexManager;
|
package/dist/scope.js
CHANGED
|
@@ -67,7 +67,7 @@ class Scope {
|
|
|
67
67
|
*/
|
|
68
68
|
query(statement, options, callback) {
|
|
69
69
|
if (options instanceof Function) {
|
|
70
|
-
callback = arguments[
|
|
70
|
+
callback = arguments[1];
|
|
71
71
|
options = undefined;
|
|
72
72
|
}
|
|
73
73
|
if (!options) {
|
|
@@ -76,7 +76,10 @@ class Scope {
|
|
|
76
76
|
const bucket = this.bucket;
|
|
77
77
|
const exec = new queryexecutor_1.QueryExecutor(bucket.conn);
|
|
78
78
|
const options_ = options;
|
|
79
|
-
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement,
|
|
79
|
+
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, {
|
|
80
|
+
...options_,
|
|
81
|
+
queryContext: `${bucket.name}.${this.name}`,
|
|
82
|
+
}), callback);
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
82
85
|
* Executes an analytics query against the cluster scoped this scope.
|
|
@@ -87,7 +90,7 @@ class Scope {
|
|
|
87
90
|
*/
|
|
88
91
|
analyticsQuery(statement, options, callback) {
|
|
89
92
|
if (options instanceof Function) {
|
|
90
|
-
callback = arguments[
|
|
93
|
+
callback = arguments[1];
|
|
91
94
|
options = undefined;
|
|
92
95
|
}
|
|
93
96
|
if (!options) {
|
|
@@ -96,7 +99,10 @@ class Scope {
|
|
|
96
99
|
const bucket = this.bucket;
|
|
97
100
|
const exec = new analyticsexecutor_1.AnalyticsExecutor(bucket.conn);
|
|
98
101
|
const options_ = options;
|
|
99
|
-
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement,
|
|
102
|
+
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, {
|
|
103
|
+
...options_,
|
|
104
|
+
queryContext: `${bucket.name}.${this.name}`,
|
|
105
|
+
}), callback);
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
exports.Scope = Scope;
|
package/dist/sdspecs.d.ts
CHANGED
|
@@ -180,7 +180,7 @@ export declare class MutateInSpec {
|
|
|
180
180
|
* Whether this operation should reference the document body or the extended
|
|
181
181
|
* attributes data for the document.
|
|
182
182
|
*/
|
|
183
|
-
static insert(path: string, value: any, options
|
|
183
|
+
static insert(path: string, value: any, options?: {
|
|
184
184
|
createPath?: boolean;
|
|
185
185
|
xattr?: boolean;
|
|
186
186
|
}): MutateInSpec;
|
package/dist/searchexecutor.js
CHANGED
|
@@ -50,6 +50,9 @@ class SearchExecutor {
|
|
|
50
50
|
if (options.disableScoring) {
|
|
51
51
|
queryObj.score = 'none';
|
|
52
52
|
}
|
|
53
|
+
if (options.includeLocations !== undefined) {
|
|
54
|
+
queryObj.includeLocations = options.includeLocations;
|
|
55
|
+
}
|
|
53
56
|
if (options.consistency) {
|
|
54
57
|
queryObjCtl.consistency = {
|
|
55
58
|
level: options.consistency,
|