@mongosh/shell-api 2.1.0 → 2.1.3
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/lib/abstract-cursor.js +176 -132
- package/lib/abstract-cursor.js.map +1 -1
- package/lib/aggregate-or-find-cursor.js +102 -51
- package/lib/aggregate-or-find-cursor.js.map +1 -1
- package/lib/aggregation-cursor.js +59 -13
- package/lib/aggregation-cursor.js.map +1 -1
- package/lib/bulk.js +248 -197
- package/lib/bulk.js.map +1 -1
- package/lib/change-stream-cursor.js +145 -101
- package/lib/change-stream-cursor.js.map +1 -1
- package/lib/collection.d.ts +2 -1
- package/lib/collection.js +1185 -1245
- package/lib/collection.js.map +1 -1
- package/lib/cursor.js +238 -203
- package/lib/cursor.js.map +1 -1
- package/lib/database.js +1180 -1206
- package/lib/database.js.map +1 -1
- package/lib/dbquery.js +68 -22
- package/lib/dbquery.js.map +1 -1
- package/lib/decorators.d.ts +39 -13
- package/lib/decorators.js +34 -34
- package/lib/decorators.js.map +1 -1
- package/lib/explainable-cursor.js +66 -20
- package/lib/explainable-cursor.js.map +1 -1
- package/lib/explainable.js +214 -179
- package/lib/explainable.js.map +1 -1
- package/lib/field-level-encryption.js +286 -235
- package/lib/field-level-encryption.js.map +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/interruptor.js.map +1 -1
- package/lib/log-entry.js.map +1 -1
- package/lib/mongo-errors.js.map +1 -1
- package/lib/mongo.d.ts +1 -1
- package/lib/mongo.js +582 -547
- package/lib/mongo.js.map +1 -1
- package/lib/plan-cache.js +108 -64
- package/lib/plan-cache.js.map +1 -1
- package/lib/replica-set.js +290 -277
- package/lib/replica-set.js.map +1 -1
- package/lib/result.js +228 -91
- package/lib/result.js.map +1 -1
- package/lib/run-command-cursor.js +59 -13
- package/lib/run-command-cursor.js.map +1 -1
- package/lib/session.js +123 -76
- package/lib/session.js.map +1 -1
- package/lib/shard.js +507 -514
- package/lib/shard.js.map +1 -1
- package/lib/shell-api.d.ts +1 -0
- package/lib/shell-api.js +313 -260
- package/lib/shell-api.js.map +1 -1
- package/lib/shell-bson.js.map +1 -1
- package/lib/shell-instance-state.js.map +1 -1
- package/lib/stream-processor.js +139 -92
- package/lib/stream-processor.js.map +1 -1
- package/lib/streams.js +158 -110
- package/lib/streams.js.map +1 -1
- package/package.json +8 -8
package/lib/database.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -18,1277 +50,1219 @@ const errors_1 = require("@mongosh/errors");
|
|
|
18
50
|
const history_1 = require("@mongosh/history");
|
|
19
51
|
const change_stream_cursor_1 = __importDefault(require("./change-stream-cursor"));
|
|
20
52
|
const error_codes_1 = require("./error-codes");
|
|
21
|
-
let Database =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
let Database = (() => {
|
|
54
|
+
let _classDecorators = [decorators_1.shellApiClassDefault];
|
|
55
|
+
let _classDescriptor;
|
|
56
|
+
let _classExtraInitializers = [];
|
|
57
|
+
let _classThis;
|
|
58
|
+
let _classSuper = decorators_1.ShellApiWithMongoClass;
|
|
59
|
+
let _instanceExtraInitializers = [];
|
|
60
|
+
let _getMongo_decorators;
|
|
61
|
+
let _getCollectionNames_decorators;
|
|
62
|
+
let _getCollectionInfos_decorators;
|
|
63
|
+
let _runCommand_decorators;
|
|
64
|
+
let _adminCommand_decorators;
|
|
65
|
+
let _aggregate_decorators;
|
|
66
|
+
let _getSiblingDB_decorators;
|
|
67
|
+
let _getCollection_decorators;
|
|
68
|
+
let _dropDatabase_decorators;
|
|
69
|
+
let _createUser_decorators;
|
|
70
|
+
let _updateUser_decorators;
|
|
71
|
+
let _changeUserPassword_decorators;
|
|
72
|
+
let _logout_decorators;
|
|
73
|
+
let _dropUser_decorators;
|
|
74
|
+
let _dropAllUsers_decorators;
|
|
75
|
+
let _auth_decorators;
|
|
76
|
+
let _grantRolesToUser_decorators;
|
|
77
|
+
let _revokeRolesFromUser_decorators;
|
|
78
|
+
let _getUser_decorators;
|
|
79
|
+
let _getUsers_decorators;
|
|
80
|
+
let _createCollection_decorators;
|
|
81
|
+
let _createEncryptedCollection_decorators;
|
|
82
|
+
let _createView_decorators;
|
|
83
|
+
let _createRole_decorators;
|
|
84
|
+
let _updateRole_decorators;
|
|
85
|
+
let _dropRole_decorators;
|
|
86
|
+
let _dropAllRoles_decorators;
|
|
87
|
+
let _grantRolesToRole_decorators;
|
|
88
|
+
let _revokeRolesFromRole_decorators;
|
|
89
|
+
let _grantPrivilegesToRole_decorators;
|
|
90
|
+
let _revokePrivilegesFromRole_decorators;
|
|
91
|
+
let _getRole_decorators;
|
|
92
|
+
let _getRoles_decorators;
|
|
93
|
+
let _currentOp_decorators;
|
|
94
|
+
let _killOp_decorators;
|
|
95
|
+
let _shutdownServer_decorators;
|
|
96
|
+
let _fsyncLock_decorators;
|
|
97
|
+
let _fsyncUnlock_decorators;
|
|
98
|
+
let _version_decorators;
|
|
99
|
+
let _serverBits_decorators;
|
|
100
|
+
let _isMaster_decorators;
|
|
101
|
+
let _hello_decorators;
|
|
102
|
+
let _serverBuildInfo_decorators;
|
|
103
|
+
let _serverStatus_decorators;
|
|
104
|
+
let _stats_decorators;
|
|
105
|
+
let _hostInfo_decorators;
|
|
106
|
+
let _serverCmdLineOpts_decorators;
|
|
107
|
+
let _rotateCertificates_decorators;
|
|
108
|
+
let _printCollectionStats_decorators;
|
|
109
|
+
let _getProfilingStatus_decorators;
|
|
110
|
+
let _setProfilingLevel_decorators;
|
|
111
|
+
let _setLogLevel_decorators;
|
|
112
|
+
let _getLogComponents_decorators;
|
|
113
|
+
let _cloneDatabase_decorators;
|
|
114
|
+
let _cloneCollection_decorators;
|
|
115
|
+
let _copyDatabase_decorators;
|
|
116
|
+
let _commandHelp_decorators;
|
|
117
|
+
let _listCommands_decorators;
|
|
118
|
+
let _getLastErrorObj_decorators;
|
|
119
|
+
let _getLastError_decorators;
|
|
120
|
+
let _printShardingStatus_decorators;
|
|
121
|
+
let _printSecondaryReplicationInfo_decorators;
|
|
122
|
+
let _getReplicationInfo_decorators;
|
|
123
|
+
let _printReplicationInfo_decorators;
|
|
124
|
+
let _printSlaveReplicationInfo_decorators;
|
|
125
|
+
let _setSecondaryOk_decorators;
|
|
126
|
+
let _watch_decorators;
|
|
127
|
+
let _sql_decorators;
|
|
128
|
+
let _checkMetadataConsistency_decorators;
|
|
129
|
+
var Database = _classThis = class extends _classSuper {
|
|
130
|
+
constructor(mongo, name, session) {
|
|
131
|
+
super();
|
|
132
|
+
this._mongo = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
133
|
+
this._cachedCollectionNames = [];
|
|
134
|
+
this._cachedHello = null;
|
|
135
|
+
this._mongo = mongo;
|
|
136
|
+
this._name = name;
|
|
137
|
+
const collections = Object.create(null);
|
|
138
|
+
this._collections = collections;
|
|
139
|
+
this._session = session;
|
|
140
|
+
const proxy = new Proxy(this, {
|
|
141
|
+
get: (target, prop) => {
|
|
142
|
+
if (prop in target) {
|
|
143
|
+
return target[prop];
|
|
144
|
+
}
|
|
145
|
+
if (typeof prop !== 'string' ||
|
|
146
|
+
prop.startsWith('_') ||
|
|
147
|
+
!(0, helpers_1.isValidCollectionName)(prop)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!collections[prop]) {
|
|
151
|
+
collections[prop] = new collection_1.default(mongo, proxy, prop);
|
|
152
|
+
}
|
|
153
|
+
return collections[prop];
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
return proxy;
|
|
53
157
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
158
|
+
async _baseOptions() {
|
|
159
|
+
const options = {};
|
|
160
|
+
if (this._session) {
|
|
161
|
+
options.session = this._session._session;
|
|
162
|
+
}
|
|
163
|
+
const maxTimeMS = await this._instanceState.shellApi.config.get('maxTimeMS');
|
|
164
|
+
if (typeof maxTimeMS === 'number') {
|
|
165
|
+
options.maxTimeMS = maxTimeMS;
|
|
166
|
+
}
|
|
167
|
+
return options;
|
|
57
168
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _a;
|
|
62
|
-
return (_a = this._cachedHello) !== null && _a !== void 0 ? _a : (await this.hello());
|
|
63
|
-
}
|
|
64
|
-
[enums_1.asPrintable]() {
|
|
65
|
-
return this._name;
|
|
66
|
-
}
|
|
67
|
-
_emitDatabaseApiCall(methodName, methodArguments = {}) {
|
|
68
|
-
this._mongo._instanceState.emitApiCallWithArgs({
|
|
69
|
-
method: methodName,
|
|
70
|
-
class: 'Database',
|
|
71
|
-
db: this._name,
|
|
72
|
-
arguments: methodArguments,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async _runCommand(cmd, options = {}) {
|
|
76
|
-
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
77
|
-
...(await this._baseOptions()),
|
|
78
|
-
...options,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async _runReadCommand(cmd, options = {}) {
|
|
82
|
-
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
83
|
-
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
84
|
-
...(await this._baseOptions()),
|
|
85
|
-
...options,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async _runAdminCommand(cmd, options = {}) {
|
|
89
|
-
return this.getSiblingDB('admin')._runCommand(cmd, {
|
|
90
|
-
...(await this._baseOptions()),
|
|
91
|
-
...options,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
async _runCursorCommand(cmd, options = {}) {
|
|
95
|
-
const providerCursor = this._mongo._serviceProvider.runCursorCommand(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
96
|
-
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
97
|
-
...(await this._baseOptions()),
|
|
98
|
-
...options,
|
|
99
|
-
});
|
|
100
|
-
const cursor = new index_1.RunCommandCursor(this._mongo, providerCursor);
|
|
101
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
102
|
-
return cursor;
|
|
103
|
-
}
|
|
104
|
-
async _runAdminCursorCommand(cmd, options = {}) {
|
|
105
|
-
return this.getSiblingDB('admin')._runCursorCommand(cmd, options);
|
|
106
|
-
}
|
|
107
|
-
async _listCollections(filter, options) {
|
|
108
|
-
return ((await this._mongo._serviceProvider.listCollections(this._name, filter, {
|
|
109
|
-
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
110
|
-
...(await this._baseOptions()),
|
|
111
|
-
...options,
|
|
112
|
-
})) || []);
|
|
113
|
-
}
|
|
114
|
-
async _getCollectionNames(options) {
|
|
115
|
-
const infos = await this._listCollections({}, { ...options, nameOnly: true });
|
|
116
|
-
this._cachedCollectionNames = infos.map((collection) => collection.name);
|
|
117
|
-
return this._cachedCollectionNames;
|
|
118
|
-
}
|
|
119
|
-
async _getCollectionNamesWithTypes(options) {
|
|
120
|
-
let collections = await this._listCollections({}, { ...options, nameOnly: true });
|
|
121
|
-
collections = collections.sort((c1, c2) => c1.name.localeCompare(c2.name));
|
|
122
|
-
this._cachedCollectionNames = collections.map((collection) => collection.name);
|
|
123
|
-
return collections.map((collection, index) => ({
|
|
124
|
-
name: collection.name,
|
|
125
|
-
badge: (0, helpers_1.getBadge)(collections, index),
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
async _getCollectionNamesForCompletion() {
|
|
129
|
-
return await Promise.race([
|
|
130
|
-
(async () => {
|
|
131
|
-
return await this._getCollectionNames({
|
|
132
|
-
readPreference: 'primaryPreferred',
|
|
133
|
-
});
|
|
134
|
-
})(),
|
|
135
|
-
(async () => {
|
|
136
|
-
await new Promise((resolve) => setTimeout(resolve, 200).unref());
|
|
137
|
-
return this._cachedCollectionNames;
|
|
138
|
-
})(),
|
|
139
|
-
]);
|
|
140
|
-
}
|
|
141
|
-
async _getLastErrorObj(w, wTimeout, j) {
|
|
142
|
-
const cmd = { getlasterror: 1 };
|
|
143
|
-
if (w) {
|
|
144
|
-
cmd.w = w;
|
|
169
|
+
async _maybeCachedHello() {
|
|
170
|
+
var _a;
|
|
171
|
+
return (_a = this._cachedHello) !== null && _a !== void 0 ? _a : (await this.hello());
|
|
145
172
|
}
|
|
146
|
-
|
|
147
|
-
|
|
173
|
+
[enums_1.asPrintable]() {
|
|
174
|
+
return this._name;
|
|
148
175
|
}
|
|
149
|
-
|
|
150
|
-
|
|
176
|
+
_emitDatabaseApiCall(methodName, methodArguments = {}) {
|
|
177
|
+
this._mongo._instanceState.emitApiCallWithArgs({
|
|
178
|
+
method: methodName,
|
|
179
|
+
class: 'Database',
|
|
180
|
+
db: this._name,
|
|
181
|
+
arguments: methodArguments,
|
|
182
|
+
});
|
|
151
183
|
}
|
|
152
|
-
|
|
153
|
-
return
|
|
184
|
+
async _runCommand(cmd, options = {}) {
|
|
185
|
+
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
186
|
+
...(await this._baseOptions()),
|
|
187
|
+
...options,
|
|
188
|
+
});
|
|
154
189
|
}
|
|
155
|
-
|
|
156
|
-
return
|
|
190
|
+
async _runReadCommand(cmd, options = {}) {
|
|
191
|
+
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
192
|
+
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
193
|
+
...(await this._baseOptions()),
|
|
194
|
+
...options,
|
|
195
|
+
});
|
|
157
196
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return this._name;
|
|
164
|
-
}
|
|
165
|
-
async getCollectionNames() {
|
|
166
|
-
this._emitDatabaseApiCall('getCollectionNames');
|
|
167
|
-
return this._getCollectionNames();
|
|
168
|
-
}
|
|
169
|
-
async getCollectionInfos(filter = {}, options = {}) {
|
|
170
|
-
this._emitDatabaseApiCall('getCollectionInfos', { filter, options });
|
|
171
|
-
return await this._listCollections(filter, options);
|
|
172
|
-
}
|
|
173
|
-
async runCommand(cmd, options) {
|
|
174
|
-
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.runCommand');
|
|
175
|
-
if (typeof cmd === 'string') {
|
|
176
|
-
cmd = { [cmd]: 1 };
|
|
197
|
+
async _runAdminCommand(cmd, options = {}) {
|
|
198
|
+
return this.getSiblingDB('admin')._runCommand(cmd, {
|
|
199
|
+
...(await this._baseOptions()),
|
|
200
|
+
...options,
|
|
201
|
+
});
|
|
177
202
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
async _runCursorCommand(cmd, options = {}) {
|
|
204
|
+
const providerCursor = this._mongo._serviceProvider.runCursorCommand(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
205
|
+
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
206
|
+
...(await this._baseOptions()),
|
|
207
|
+
...options,
|
|
208
|
+
});
|
|
209
|
+
const cursor = new index_1.RunCommandCursor(this._mongo, providerCursor);
|
|
210
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
211
|
+
return cursor;
|
|
212
|
+
}
|
|
213
|
+
async _runAdminCursorCommand(cmd, options = {}) {
|
|
214
|
+
return this.getSiblingDB('admin')._runCursorCommand(cmd, options);
|
|
215
|
+
}
|
|
216
|
+
async _listCollections(filter, options) {
|
|
217
|
+
return ((await this._mongo._serviceProvider.listCollections(this._name, filter, {
|
|
218
|
+
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
219
|
+
...(await this._baseOptions()),
|
|
220
|
+
...options,
|
|
221
|
+
})) || []);
|
|
222
|
+
}
|
|
223
|
+
async _getCollectionNames(options) {
|
|
224
|
+
const infos = await this._listCollections({}, { ...options, nameOnly: true });
|
|
225
|
+
this._cachedCollectionNames = infos.map((collection) => collection.name);
|
|
226
|
+
return this._cachedCollectionNames;
|
|
227
|
+
}
|
|
228
|
+
async _getCollectionNamesWithTypes(options) {
|
|
229
|
+
let collections = await this._listCollections({}, { ...options, nameOnly: true });
|
|
230
|
+
collections = collections.sort((c1, c2) => c1.name.localeCompare(c2.name));
|
|
231
|
+
this._cachedCollectionNames = collections.map((collection) => collection.name);
|
|
232
|
+
return collections.map((collection, index) => ({
|
|
233
|
+
name: collection.name,
|
|
234
|
+
badge: (0, helpers_1.getBadge)(collections, index),
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
async _getCollectionNamesForCompletion() {
|
|
238
|
+
return await Promise.race([
|
|
239
|
+
(async () => {
|
|
240
|
+
return await this._getCollectionNames({
|
|
241
|
+
readPreference: 'primaryPreferred',
|
|
242
|
+
});
|
|
243
|
+
})(),
|
|
244
|
+
(async () => {
|
|
245
|
+
await new Promise((resolve) => setTimeout(resolve, 200).unref());
|
|
246
|
+
return this._cachedCollectionNames;
|
|
247
|
+
})(),
|
|
248
|
+
]);
|
|
249
|
+
}
|
|
250
|
+
async _getLastErrorObj(w, wTimeout, j) {
|
|
251
|
+
const cmd = { getlasterror: 1 };
|
|
252
|
+
if (w) {
|
|
253
|
+
cmd.w = w;
|
|
254
|
+
}
|
|
255
|
+
if (wTimeout) {
|
|
256
|
+
cmd.wtimeout = wTimeout;
|
|
257
|
+
}
|
|
258
|
+
if (j !== undefined) {
|
|
259
|
+
cmd.j = j;
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
return await this._mongo._serviceProvider.runCommand(this._name, cmd, await this._baseOptions());
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
return e;
|
|
266
|
+
}
|
|
181
267
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
async adminCommand(cmd) {
|
|
185
|
-
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.adminCommand');
|
|
186
|
-
if (typeof cmd === 'string') {
|
|
187
|
-
cmd = { [cmd]: 1 };
|
|
268
|
+
getMongo() {
|
|
269
|
+
return this._mongo;
|
|
188
270
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this._emitDatabaseApiCall('adminCommand', { cmd });
|
|
271
|
+
getName() {
|
|
272
|
+
return this._name;
|
|
192
273
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
(0, helpers_1.assertArgsDefinedType)([pipeline], [true], 'Database.aggregate');
|
|
197
|
-
this._emitDatabaseApiCall('aggregate', { options, pipeline });
|
|
198
|
-
const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
|
|
199
|
-
const providerCursor = this._mongo._serviceProvider.aggregateDb(this._name, pipeline, { ...(await this._baseOptions()), ...aggOptions }, dbOptions);
|
|
200
|
-
const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
|
|
201
|
-
if (explain) {
|
|
202
|
-
return await cursor.explain(explain);
|
|
203
|
-
}
|
|
204
|
-
else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
|
|
205
|
-
await cursor.hasNext();
|
|
206
|
-
}
|
|
207
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
208
|
-
return cursor;
|
|
209
|
-
}
|
|
210
|
-
getSiblingDB(db) {
|
|
211
|
-
(0, helpers_1.assertArgsDefinedType)([db], ['string'], 'Database.getSiblingDB');
|
|
212
|
-
this._emitDatabaseApiCall('getSiblingDB', { db });
|
|
213
|
-
if (this._session) {
|
|
214
|
-
return this._session.getDatabase(db);
|
|
274
|
+
async getCollectionNames() {
|
|
275
|
+
this._emitDatabaseApiCall('getCollectionNames');
|
|
276
|
+
return this._getCollectionNames();
|
|
215
277
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
(0, helpers_1.assertArgsDefinedType)([coll], ['string'], 'Database.getColl');
|
|
220
|
-
this._emitDatabaseApiCall('getCollection', { coll });
|
|
221
|
-
if (!(0, helpers_1.isValidCollectionName)(coll)) {
|
|
222
|
-
throw new errors_1.MongoshInvalidInputError(`Invalid collection name: ${coll}`, errors_1.CommonErrors.InvalidArgument);
|
|
278
|
+
async getCollectionInfos(filter = {}, options = {}) {
|
|
279
|
+
this._emitDatabaseApiCall('getCollectionInfos', { filter, options });
|
|
280
|
+
return await this._listCollections(filter, options);
|
|
223
281
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
282
|
+
async runCommand(cmd, options) {
|
|
283
|
+
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.runCommand');
|
|
284
|
+
if (typeof cmd === 'string') {
|
|
285
|
+
cmd = { [cmd]: 1 };
|
|
286
|
+
}
|
|
287
|
+
const hiddenCommands = new RegExp(history_1.HIDDEN_COMMANDS);
|
|
288
|
+
if (!Object.keys(cmd).some((k) => hiddenCommands.test(k))) {
|
|
289
|
+
this._emitDatabaseApiCall('runCommand', { cmd, options });
|
|
290
|
+
}
|
|
291
|
+
return this._runCommand(cmd, options);
|
|
227
292
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return await this._runCommand(orderedCmd);
|
|
262
|
-
}
|
|
263
|
-
async updateUser(username, userDoc, writeConcern) {
|
|
264
|
-
(0, helpers_1.assertArgsDefinedType)([username, userDoc], ['string', 'object'], 'Database.updateUser');
|
|
265
|
-
this._emitDatabaseApiCall('updateUser', {});
|
|
266
|
-
if (userDoc.passwordDigestor &&
|
|
267
|
-
userDoc.passwordDigestor !== 'server' &&
|
|
268
|
-
userDoc.passwordDigestor !== 'client') {
|
|
269
|
-
throw new errors_1.MongoshInvalidInputError(`Invalid field: passwordDigestor must be 'client' or 'server', got ${userDoc.passwordDigestor}`, errors_1.CommonErrors.InvalidArgument);
|
|
270
|
-
}
|
|
271
|
-
const command = (0, helpers_1.adaptOptions)({ passwordDigestor: null }, {
|
|
272
|
-
updateUser: username,
|
|
273
|
-
}, userDoc);
|
|
274
|
-
if (writeConcern) {
|
|
275
|
-
command.writeConcern = writeConcern;
|
|
276
|
-
}
|
|
277
|
-
const digestPwd = (0, helpers_1.processDigestPassword)(username, userDoc.passwordDigestor, command);
|
|
278
|
-
const orderedCmd = {
|
|
279
|
-
updateUser: command.updateUser,
|
|
280
|
-
...command,
|
|
281
|
-
...digestPwd,
|
|
282
|
-
};
|
|
283
|
-
return await this._runCommand(orderedCmd);
|
|
284
|
-
}
|
|
285
|
-
async changeUserPassword(username, password, writeConcern) {
|
|
286
|
-
(0, helpers_1.assertArgsDefinedType)([username, password], ['string', 'string'], 'Database.changeUserPassword');
|
|
287
|
-
this._emitDatabaseApiCall('changeUserPassword', {});
|
|
288
|
-
const command = (0, helpers_1.adaptOptions)({}, {
|
|
289
|
-
updateUser: username,
|
|
290
|
-
pwd: password,
|
|
291
|
-
}, {});
|
|
292
|
-
if (writeConcern) {
|
|
293
|
-
command.writeConcern = writeConcern;
|
|
294
|
-
}
|
|
295
|
-
const orderedCmd = { updateUser: command.updateUser, ...command };
|
|
296
|
-
return await this._runCommand(orderedCmd);
|
|
297
|
-
}
|
|
298
|
-
async logout() {
|
|
299
|
-
this._emitDatabaseApiCall('logout', {});
|
|
300
|
-
this._mongo._instanceState.currentCursor = null;
|
|
301
|
-
return await this._runCommand({ logout: 1 });
|
|
302
|
-
}
|
|
303
|
-
async dropUser(username, writeConcern) {
|
|
304
|
-
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.dropUser');
|
|
305
|
-
this._emitDatabaseApiCall('dropUser', {});
|
|
306
|
-
const cmd = { dropUser: username };
|
|
307
|
-
if (writeConcern) {
|
|
308
|
-
cmd.writeConcern = writeConcern;
|
|
309
|
-
}
|
|
310
|
-
return await this._runCommand(cmd);
|
|
311
|
-
}
|
|
312
|
-
async dropAllUsers(writeConcern) {
|
|
313
|
-
this._emitDatabaseApiCall('dropAllUsers', {});
|
|
314
|
-
const cmd = { dropAllUsersFromDatabase: 1 };
|
|
315
|
-
if (writeConcern) {
|
|
316
|
-
cmd.writeConcern = writeConcern;
|
|
293
|
+
async adminCommand(cmd) {
|
|
294
|
+
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.adminCommand');
|
|
295
|
+
if (typeof cmd === 'string') {
|
|
296
|
+
cmd = { [cmd]: 1 };
|
|
297
|
+
}
|
|
298
|
+
const hiddenCommands = new RegExp(history_1.HIDDEN_COMMANDS);
|
|
299
|
+
if (!Object.keys(cmd).some((k) => hiddenCommands.test(k))) {
|
|
300
|
+
this._emitDatabaseApiCall('adminCommand', { cmd });
|
|
301
|
+
}
|
|
302
|
+
return await this._runAdminCommand(cmd, {});
|
|
303
|
+
}
|
|
304
|
+
async aggregate(pipeline, options) {
|
|
305
|
+
(0, helpers_1.assertArgsDefinedType)([pipeline], [true], 'Database.aggregate');
|
|
306
|
+
this._emitDatabaseApiCall('aggregate', { options, pipeline });
|
|
307
|
+
const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
|
|
308
|
+
const providerCursor = this._mongo._serviceProvider.aggregateDb(this._name, pipeline, { ...(await this._baseOptions()), ...aggOptions }, dbOptions);
|
|
309
|
+
const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
|
|
310
|
+
if (explain) {
|
|
311
|
+
return await cursor.explain(explain);
|
|
312
|
+
}
|
|
313
|
+
else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
|
|
314
|
+
await cursor.hasNext();
|
|
315
|
+
}
|
|
316
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
317
|
+
return cursor;
|
|
318
|
+
}
|
|
319
|
+
getSiblingDB(db) {
|
|
320
|
+
(0, helpers_1.assertArgsDefinedType)([db], ['string'], 'Database.getSiblingDB');
|
|
321
|
+
this._emitDatabaseApiCall('getSiblingDB', { db });
|
|
322
|
+
if (this._session) {
|
|
323
|
+
return this._session.getDatabase(db);
|
|
324
|
+
}
|
|
325
|
+
return this._mongo._getDb(db);
|
|
317
326
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
327
|
+
getCollection(coll) {
|
|
328
|
+
(0, helpers_1.assertArgsDefinedType)([coll], ['string'], 'Database.getColl');
|
|
329
|
+
this._emitDatabaseApiCall('getCollection', { coll });
|
|
330
|
+
if (!(0, helpers_1.isValidCollectionName)(coll)) {
|
|
331
|
+
throw new errors_1.MongoshInvalidInputError(`Invalid collection name: ${coll}`, errors_1.CommonErrors.InvalidArgument);
|
|
332
|
+
}
|
|
333
|
+
const collections = this._collections;
|
|
334
|
+
if (!collections[coll]) {
|
|
335
|
+
collections[coll] = new collection_1.default(this._mongo, this, coll);
|
|
336
|
+
}
|
|
337
|
+
return collections[coll];
|
|
338
|
+
}
|
|
339
|
+
async dropDatabase(writeConcern) {
|
|
340
|
+
return await this._mongo._serviceProvider.dropDatabase(this._name, {
|
|
341
|
+
...(await this._baseOptions()),
|
|
342
|
+
writeConcern,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
async createUser(user, writeConcern) {
|
|
346
|
+
(0, helpers_1.assertArgsDefinedType)([user], ['object'], 'Database.createUser');
|
|
347
|
+
(0, helpers_1.assertKeysDefined)(user, ['user', 'roles']);
|
|
348
|
+
if (this._name === '$external') {
|
|
349
|
+
if ('pwd' in user) {
|
|
350
|
+
throw new errors_1.MongoshInvalidInputError('Cannot set password for users on the $external database', errors_1.CommonErrors.InvalidArgument);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
(0, helpers_1.assertKeysDefined)(user, ['pwd']);
|
|
355
|
+
}
|
|
356
|
+
this._emitDatabaseApiCall('createUser', {});
|
|
357
|
+
if (user.createUser) {
|
|
358
|
+
throw new errors_1.MongoshInvalidInputError('Cannot set createUser field in helper method', errors_1.CommonErrors.InvalidArgument);
|
|
359
|
+
}
|
|
360
|
+
const command = (0, helpers_1.adaptOptions)({ user: 'createUser', passwordDigestor: null }, {}, user);
|
|
361
|
+
if (writeConcern) {
|
|
362
|
+
command.writeConcern = writeConcern;
|
|
363
|
+
}
|
|
364
|
+
const digestPwd = (0, helpers_1.processDigestPassword)(user.user, user.passwordDigestor, command);
|
|
365
|
+
const orderedCmd = {
|
|
366
|
+
createUser: command.createUser,
|
|
367
|
+
...command,
|
|
368
|
+
...digestPwd,
|
|
369
|
+
};
|
|
370
|
+
return await this._runCommand(orderedCmd);
|
|
371
|
+
}
|
|
372
|
+
async updateUser(username, userDoc, writeConcern) {
|
|
373
|
+
(0, helpers_1.assertArgsDefinedType)([username, userDoc], ['string', 'object'], 'Database.updateUser');
|
|
374
|
+
this._emitDatabaseApiCall('updateUser', {});
|
|
375
|
+
if (userDoc.passwordDigestor &&
|
|
376
|
+
userDoc.passwordDigestor !== 'server' &&
|
|
377
|
+
userDoc.passwordDigestor !== 'client') {
|
|
378
|
+
throw new errors_1.MongoshInvalidInputError(`Invalid field: passwordDigestor must be 'client' or 'server', got ${userDoc.passwordDigestor}`, errors_1.CommonErrors.InvalidArgument);
|
|
379
|
+
}
|
|
380
|
+
const command = (0, helpers_1.adaptOptions)({ passwordDigestor: null }, {
|
|
381
|
+
updateUser: username,
|
|
382
|
+
}, userDoc);
|
|
383
|
+
if (writeConcern) {
|
|
384
|
+
command.writeConcern = writeConcern;
|
|
385
|
+
}
|
|
386
|
+
const digestPwd = (0, helpers_1.processDigestPassword)(username, userDoc.passwordDigestor, command);
|
|
387
|
+
const orderedCmd = {
|
|
388
|
+
updateUser: command.updateUser,
|
|
389
|
+
...command,
|
|
390
|
+
...digestPwd,
|
|
391
|
+
};
|
|
392
|
+
return await this._runCommand(orderedCmd);
|
|
393
|
+
}
|
|
394
|
+
async changeUserPassword(username, password, writeConcern) {
|
|
395
|
+
(0, helpers_1.assertArgsDefinedType)([username, password], ['string', 'string'], 'Database.changeUserPassword');
|
|
396
|
+
this._emitDatabaseApiCall('changeUserPassword', {});
|
|
397
|
+
const command = (0, helpers_1.adaptOptions)({}, {
|
|
398
|
+
updateUser: username,
|
|
399
|
+
pwd: password,
|
|
400
|
+
}, {});
|
|
401
|
+
if (writeConcern) {
|
|
402
|
+
command.writeConcern = writeConcern;
|
|
403
|
+
}
|
|
404
|
+
const orderedCmd = { updateUser: command.updateUser, ...command };
|
|
405
|
+
return await this._runCommand(orderedCmd);
|
|
406
|
+
}
|
|
407
|
+
async logout() {
|
|
408
|
+
this._emitDatabaseApiCall('logout', {});
|
|
409
|
+
this._mongo._instanceState.currentCursor = null;
|
|
410
|
+
return await this._runCommand({ logout: 1 });
|
|
411
|
+
}
|
|
412
|
+
async dropUser(username, writeConcern) {
|
|
413
|
+
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.dropUser');
|
|
414
|
+
this._emitDatabaseApiCall('dropUser', {});
|
|
415
|
+
const cmd = { dropUser: username };
|
|
416
|
+
if (writeConcern) {
|
|
417
|
+
cmd.writeConcern = writeConcern;
|
|
418
|
+
}
|
|
419
|
+
return await this._runCommand(cmd);
|
|
420
|
+
}
|
|
421
|
+
async dropAllUsers(writeConcern) {
|
|
422
|
+
this._emitDatabaseApiCall('dropAllUsers', {});
|
|
423
|
+
const cmd = { dropAllUsersFromDatabase: 1 };
|
|
424
|
+
if (writeConcern) {
|
|
425
|
+
cmd.writeConcern = writeConcern;
|
|
426
|
+
}
|
|
427
|
+
return await this._runCommand(cmd);
|
|
428
|
+
}
|
|
429
|
+
async auth(...args) {
|
|
430
|
+
this._emitDatabaseApiCall('auth', {});
|
|
431
|
+
let authDoc;
|
|
432
|
+
if (args.length === 1) {
|
|
433
|
+
const { evaluationListener } = this._mongo._instanceState;
|
|
434
|
+
if (typeof args[0] === 'string' && evaluationListener.onPrompt) {
|
|
435
|
+
authDoc = {
|
|
436
|
+
user: args[0],
|
|
437
|
+
pwd: await evaluationListener.onPrompt('Enter password', 'password'),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
authDoc = args[0];
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
else if (args.length === 2) {
|
|
326
445
|
authDoc = {
|
|
327
446
|
user: args[0],
|
|
328
|
-
pwd:
|
|
447
|
+
pwd: args[1],
|
|
329
448
|
};
|
|
330
449
|
}
|
|
331
450
|
else {
|
|
332
|
-
|
|
451
|
+
throw new errors_1.MongoshInvalidInputError('auth expects (username), (username, password), or ({ user: username, pwd: password })', errors_1.CommonErrors.InvalidArgument);
|
|
452
|
+
}
|
|
453
|
+
if ((!authDoc.user || !authDoc.pwd) && !authDoc.mechanism) {
|
|
454
|
+
throw new errors_1.MongoshInvalidInputError("auth expects user document with at least 'user' and 'pwd' or 'mechanism' fields", errors_1.CommonErrors.InvalidArgument);
|
|
455
|
+
}
|
|
456
|
+
if ('digestPassword' in authDoc) {
|
|
457
|
+
throw new errors_1.MongoshUnimplementedError('digestPassword is not supported for authentication.', errors_1.CommonErrors.NotImplemented);
|
|
458
|
+
}
|
|
459
|
+
authDoc.authDb = this._name;
|
|
460
|
+
this._mongo._instanceState.currentCursor = null;
|
|
461
|
+
return await this._mongo._serviceProvider.authenticate(authDoc);
|
|
462
|
+
}
|
|
463
|
+
async grantRolesToUser(username, roles, writeConcern) {
|
|
464
|
+
(0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.grantRolesToUser');
|
|
465
|
+
this._emitDatabaseApiCall('grantRolesToUser', {});
|
|
466
|
+
const cmd = { grantRolesToUser: username, roles: roles };
|
|
467
|
+
if (writeConcern) {
|
|
468
|
+
cmd.writeConcern = writeConcern;
|
|
469
|
+
}
|
|
470
|
+
return await this._runCommand(cmd);
|
|
471
|
+
}
|
|
472
|
+
async revokeRolesFromUser(username, roles, writeConcern) {
|
|
473
|
+
(0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.revokeRolesFromUser');
|
|
474
|
+
this._emitDatabaseApiCall('revokeRolesFromUser', {});
|
|
475
|
+
const cmd = { revokeRolesFromUser: username, roles: roles };
|
|
476
|
+
if (writeConcern) {
|
|
477
|
+
cmd.writeConcern = writeConcern;
|
|
333
478
|
}
|
|
479
|
+
return await this._runCommand(cmd);
|
|
480
|
+
}
|
|
481
|
+
async getUser(username, options = {}) {
|
|
482
|
+
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.getUser');
|
|
483
|
+
this._emitDatabaseApiCall('getUser', { username: username });
|
|
484
|
+
const command = (0, helpers_1.adaptOptions)({}, { usersInfo: { user: username, db: this._name } }, options);
|
|
485
|
+
const result = await this._runReadCommand(command);
|
|
486
|
+
if (result.users === undefined) {
|
|
487
|
+
throw new errors_1.MongoshInternalError('No users were returned from the userInfo command');
|
|
488
|
+
}
|
|
489
|
+
for (let i = 0; i < result.users.length; i++) {
|
|
490
|
+
if (result.users[i].user === username) {
|
|
491
|
+
return result.users[i];
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
async getUsers(options = {}) {
|
|
497
|
+
this._emitDatabaseApiCall('getUsers', { options: options });
|
|
498
|
+
const command = (0, helpers_1.adaptOptions)({}, { usersInfo: 1 }, options);
|
|
499
|
+
return await this._runReadCommand(command);
|
|
500
|
+
}
|
|
501
|
+
async createCollection(name, options = {}) {
|
|
502
|
+
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.createCollection');
|
|
503
|
+
this._emitDatabaseApiCall('createCollection', {
|
|
504
|
+
name: name,
|
|
505
|
+
options: options,
|
|
506
|
+
});
|
|
507
|
+
return await this._mongo._serviceProvider.createCollection(this._name, name, { ...(await this._baseOptions()), ...options });
|
|
334
508
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
509
|
+
async createEncryptedCollection(name, options) {
|
|
510
|
+
this._emitDatabaseApiCall('createEncryptedCollection', {
|
|
511
|
+
name: name,
|
|
512
|
+
options: options,
|
|
513
|
+
});
|
|
514
|
+
return this._mongo
|
|
515
|
+
.getClientEncryption()
|
|
516
|
+
.createEncryptedCollection(this._name, name, options);
|
|
517
|
+
}
|
|
518
|
+
async createView(name, source, pipeline, options = {}) {
|
|
519
|
+
(0, helpers_1.assertArgsDefinedType)([name, source, pipeline], ['string', 'string', true], 'Database.createView');
|
|
520
|
+
this._emitDatabaseApiCall('createView', {
|
|
521
|
+
name,
|
|
522
|
+
source,
|
|
523
|
+
pipeline,
|
|
524
|
+
options,
|
|
525
|
+
});
|
|
526
|
+
const ccOpts = {
|
|
527
|
+
...(await this._baseOptions()),
|
|
528
|
+
viewOn: source,
|
|
529
|
+
pipeline: pipeline,
|
|
339
530
|
};
|
|
531
|
+
if (options.collation) {
|
|
532
|
+
ccOpts.collation = options.collation;
|
|
533
|
+
}
|
|
534
|
+
return await this._mongo._serviceProvider.createCollection(this._name, name, ccOpts);
|
|
535
|
+
}
|
|
536
|
+
async createRole(role, writeConcern) {
|
|
537
|
+
(0, helpers_1.assertArgsDefinedType)([role], ['object'], 'Database.createRole');
|
|
538
|
+
(0, helpers_1.assertKeysDefined)(role, ['role', 'privileges', 'roles']);
|
|
539
|
+
this._emitDatabaseApiCall('createRole', {});
|
|
540
|
+
if (role.createRole) {
|
|
541
|
+
throw new errors_1.MongoshInvalidInputError('Cannot set createRole field in helper method', errors_1.CommonErrors.InvalidArgument);
|
|
542
|
+
}
|
|
543
|
+
const command = (0, helpers_1.adaptOptions)({ role: 'createRole' }, {}, role);
|
|
544
|
+
if (writeConcern) {
|
|
545
|
+
command.writeConcern = writeConcern;
|
|
546
|
+
}
|
|
547
|
+
const orderedCmd = { createRole: command.createRole, ...command };
|
|
548
|
+
return await this._runCommand(orderedCmd);
|
|
549
|
+
}
|
|
550
|
+
async updateRole(rolename, roleDoc, writeConcern) {
|
|
551
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, roleDoc], ['string', 'object'], 'Database.updateRole');
|
|
552
|
+
this._emitDatabaseApiCall('updateRole', {});
|
|
553
|
+
const command = (0, helpers_1.adaptOptions)({}, {
|
|
554
|
+
updateRole: rolename,
|
|
555
|
+
}, roleDoc);
|
|
556
|
+
if (writeConcern) {
|
|
557
|
+
command.writeConcern = writeConcern;
|
|
558
|
+
}
|
|
559
|
+
const orderedCmd = { updateRole: command.updateRole, ...command };
|
|
560
|
+
return await this._runCommand(orderedCmd);
|
|
561
|
+
}
|
|
562
|
+
async dropRole(rolename, writeConcern) {
|
|
563
|
+
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.dropRole');
|
|
564
|
+
this._emitDatabaseApiCall('dropRole', {});
|
|
565
|
+
const cmd = { dropRole: rolename };
|
|
566
|
+
if (writeConcern) {
|
|
567
|
+
cmd.writeConcern = writeConcern;
|
|
568
|
+
}
|
|
569
|
+
return await this._runCommand(cmd);
|
|
340
570
|
}
|
|
341
|
-
|
|
342
|
-
|
|
571
|
+
async dropAllRoles(writeConcern) {
|
|
572
|
+
this._emitDatabaseApiCall('dropAllRoles', {});
|
|
573
|
+
const cmd = { dropAllRolesFromDatabase: 1 };
|
|
574
|
+
if (writeConcern) {
|
|
575
|
+
cmd.writeConcern = writeConcern;
|
|
576
|
+
}
|
|
577
|
+
return await this._runCommand(cmd);
|
|
578
|
+
}
|
|
579
|
+
async grantRolesToRole(rolename, roles, writeConcern) {
|
|
580
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.grantRolesToRole');
|
|
581
|
+
this._emitDatabaseApiCall('grantRolesToRole', {});
|
|
582
|
+
const cmd = { grantRolesToRole: rolename, roles: roles };
|
|
583
|
+
if (writeConcern) {
|
|
584
|
+
cmd.writeConcern = writeConcern;
|
|
585
|
+
}
|
|
586
|
+
return await this._runCommand(cmd);
|
|
587
|
+
}
|
|
588
|
+
async revokeRolesFromRole(rolename, roles, writeConcern) {
|
|
589
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.revokeRolesFromRole');
|
|
590
|
+
this._emitDatabaseApiCall('revokeRolesFromRole', {});
|
|
591
|
+
const cmd = { revokeRolesFromRole: rolename, roles: roles };
|
|
592
|
+
if (writeConcern) {
|
|
593
|
+
cmd.writeConcern = writeConcern;
|
|
594
|
+
}
|
|
595
|
+
return await this._runCommand(cmd);
|
|
596
|
+
}
|
|
597
|
+
async grantPrivilegesToRole(rolename, privileges, writeConcern) {
|
|
598
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.grantPrivilegesToRole');
|
|
599
|
+
this._emitDatabaseApiCall('grantPrivilegesToRole', {});
|
|
600
|
+
const cmd = {
|
|
601
|
+
grantPrivilegesToRole: rolename,
|
|
602
|
+
privileges: privileges,
|
|
603
|
+
};
|
|
604
|
+
if (writeConcern) {
|
|
605
|
+
cmd.writeConcern = writeConcern;
|
|
606
|
+
}
|
|
607
|
+
return await this._runCommand(cmd);
|
|
608
|
+
}
|
|
609
|
+
async revokePrivilegesFromRole(rolename, privileges, writeConcern) {
|
|
610
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.revokePrivilegesFromRole');
|
|
611
|
+
this._emitDatabaseApiCall('revokePrivilegesFromRole', {});
|
|
612
|
+
const cmd = {
|
|
613
|
+
revokePrivilegesFromRole: rolename,
|
|
614
|
+
privileges: privileges,
|
|
615
|
+
};
|
|
616
|
+
if (writeConcern) {
|
|
617
|
+
cmd.writeConcern = writeConcern;
|
|
618
|
+
}
|
|
619
|
+
return await this._runCommand(cmd);
|
|
620
|
+
}
|
|
621
|
+
async getRole(rolename, options = {}) {
|
|
622
|
+
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.getRole');
|
|
623
|
+
this._emitDatabaseApiCall('getRole', { rolename: rolename });
|
|
624
|
+
const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: { role: rolename, db: this._name } }, options);
|
|
625
|
+
const result = await this._runReadCommand(command);
|
|
626
|
+
if (result.roles === undefined) {
|
|
627
|
+
throw new errors_1.MongoshInternalError('No roles returned from rolesInfo command');
|
|
628
|
+
}
|
|
629
|
+
for (let i = 0; i < result.roles.length; i++) {
|
|
630
|
+
if (result.roles[i].role === rolename) {
|
|
631
|
+
return result.roles[i];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
async getRoles(options = {}) {
|
|
637
|
+
this._emitDatabaseApiCall('getRoles', { options: options });
|
|
638
|
+
const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: 1 }, options);
|
|
639
|
+
return await this._runReadCommand(command);
|
|
640
|
+
}
|
|
641
|
+
async _getCurrentOperations(opts) {
|
|
642
|
+
const legacyCurrentOpOptions = typeof opts === 'boolean'
|
|
643
|
+
? { $all: opts, $ownOps: false }
|
|
644
|
+
: { $all: !!opts.$all, $ownOps: !!opts.$ownOps };
|
|
645
|
+
const pipeline = [
|
|
646
|
+
{
|
|
647
|
+
$currentOp: {
|
|
648
|
+
allUsers: !legacyCurrentOpOptions.$ownOps,
|
|
649
|
+
idleConnections: legacyCurrentOpOptions.$all,
|
|
650
|
+
truncateOps: false,
|
|
651
|
+
},
|
|
652
|
+
},
|
|
653
|
+
];
|
|
654
|
+
if (typeof opts === 'object') {
|
|
655
|
+
const matchingFilters = {};
|
|
656
|
+
for (const filtername of Object.keys(opts)) {
|
|
657
|
+
if (filtername !== '$ownOps' &&
|
|
658
|
+
filtername !== '$all' &&
|
|
659
|
+
filtername !== '$truncateOps') {
|
|
660
|
+
matchingFilters[filtername] = opts[filtername];
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
pipeline.push({ $match: matchingFilters });
|
|
664
|
+
}
|
|
665
|
+
const adminDb = this.getSiblingDB('admin');
|
|
666
|
+
const aggregateOptions = { $readPreference: { mode: 'primaryPreferred' } };
|
|
667
|
+
try {
|
|
668
|
+
const cursor = await adminDb.aggregate(pipeline, aggregateOptions);
|
|
669
|
+
return await cursor.toArray();
|
|
670
|
+
}
|
|
671
|
+
catch (error) {
|
|
672
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'FailedToParse') {
|
|
673
|
+
delete pipeline[0].$currentOp.truncateOps;
|
|
674
|
+
const cursor = await adminDb.aggregate(pipeline, aggregateOptions);
|
|
675
|
+
return await cursor.toArray();
|
|
676
|
+
}
|
|
677
|
+
throw error;
|
|
678
|
+
}
|
|
343
679
|
}
|
|
344
|
-
|
|
345
|
-
|
|
680
|
+
async currentOp(opts = {}) {
|
|
681
|
+
this._emitDatabaseApiCall('currentOp', { opts: opts });
|
|
682
|
+
const currentOps = await this._getCurrentOperations(opts);
|
|
683
|
+
return {
|
|
684
|
+
inprog: currentOps,
|
|
685
|
+
ok: 1,
|
|
686
|
+
};
|
|
346
687
|
}
|
|
347
|
-
|
|
348
|
-
|
|
688
|
+
async killOp(opId) {
|
|
689
|
+
this._emitDatabaseApiCall('killOp', { opId });
|
|
690
|
+
return await this._runAdminCommand({
|
|
691
|
+
killOp: 1,
|
|
692
|
+
op: opId,
|
|
693
|
+
});
|
|
349
694
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this._emitDatabaseApiCall('grantRolesToUser', {});
|
|
357
|
-
const cmd = { grantRolesToUser: username, roles: roles };
|
|
358
|
-
if (writeConcern) {
|
|
359
|
-
cmd.writeConcern = writeConcern;
|
|
360
|
-
}
|
|
361
|
-
return await this._runCommand(cmd);
|
|
362
|
-
}
|
|
363
|
-
async revokeRolesFromUser(username, roles, writeConcern) {
|
|
364
|
-
(0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.revokeRolesFromUser');
|
|
365
|
-
this._emitDatabaseApiCall('revokeRolesFromUser', {});
|
|
366
|
-
const cmd = { revokeRolesFromUser: username, roles: roles };
|
|
367
|
-
if (writeConcern) {
|
|
368
|
-
cmd.writeConcern = writeConcern;
|
|
369
|
-
}
|
|
370
|
-
return await this._runCommand(cmd);
|
|
371
|
-
}
|
|
372
|
-
async getUser(username, options = {}) {
|
|
373
|
-
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.getUser');
|
|
374
|
-
this._emitDatabaseApiCall('getUser', { username: username });
|
|
375
|
-
const command = (0, helpers_1.adaptOptions)({}, { usersInfo: { user: username, db: this._name } }, options);
|
|
376
|
-
const result = await this._runReadCommand(command);
|
|
377
|
-
if (result.users === undefined) {
|
|
378
|
-
throw new errors_1.MongoshInternalError('No users were returned from the userInfo command');
|
|
695
|
+
async shutdownServer(opts = {}) {
|
|
696
|
+
this._emitDatabaseApiCall('shutdownServer', { opts: opts });
|
|
697
|
+
return await this._runAdminCommand({
|
|
698
|
+
shutdown: 1,
|
|
699
|
+
...opts,
|
|
700
|
+
});
|
|
379
701
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
702
|
+
async fsyncLock() {
|
|
703
|
+
this._emitDatabaseApiCall('fsyncLock', {});
|
|
704
|
+
return await this._runAdminCommand({
|
|
705
|
+
fsync: 1,
|
|
706
|
+
lock: true,
|
|
707
|
+
});
|
|
384
708
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return await this._runReadCommand(command);
|
|
391
|
-
}
|
|
392
|
-
async createCollection(name, options = {}) {
|
|
393
|
-
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.createCollection');
|
|
394
|
-
this._emitDatabaseApiCall('createCollection', {
|
|
395
|
-
name: name,
|
|
396
|
-
options: options,
|
|
397
|
-
});
|
|
398
|
-
return await this._mongo._serviceProvider.createCollection(this._name, name, { ...(await this._baseOptions()), ...options });
|
|
399
|
-
}
|
|
400
|
-
async createEncryptedCollection(name, options) {
|
|
401
|
-
this._emitDatabaseApiCall('createEncryptedCollection', {
|
|
402
|
-
name: name,
|
|
403
|
-
options: options,
|
|
404
|
-
});
|
|
405
|
-
return this._mongo
|
|
406
|
-
.getClientEncryption()
|
|
407
|
-
.createEncryptedCollection(this._name, name, options);
|
|
408
|
-
}
|
|
409
|
-
async createView(name, source, pipeline, options = {}) {
|
|
410
|
-
(0, helpers_1.assertArgsDefinedType)([name, source, pipeline], ['string', 'string', true], 'Database.createView');
|
|
411
|
-
this._emitDatabaseApiCall('createView', {
|
|
412
|
-
name,
|
|
413
|
-
source,
|
|
414
|
-
pipeline,
|
|
415
|
-
options,
|
|
416
|
-
});
|
|
417
|
-
const ccOpts = {
|
|
418
|
-
...(await this._baseOptions()),
|
|
419
|
-
viewOn: source,
|
|
420
|
-
pipeline: pipeline,
|
|
421
|
-
};
|
|
422
|
-
if (options.collation) {
|
|
423
|
-
ccOpts.collation = options.collation;
|
|
424
|
-
}
|
|
425
|
-
return await this._mongo._serviceProvider.createCollection(this._name, name, ccOpts);
|
|
426
|
-
}
|
|
427
|
-
async createRole(role, writeConcern) {
|
|
428
|
-
(0, helpers_1.assertArgsDefinedType)([role], ['object'], 'Database.createRole');
|
|
429
|
-
(0, helpers_1.assertKeysDefined)(role, ['role', 'privileges', 'roles']);
|
|
430
|
-
this._emitDatabaseApiCall('createRole', {});
|
|
431
|
-
if (role.createRole) {
|
|
432
|
-
throw new errors_1.MongoshInvalidInputError('Cannot set createRole field in helper method', errors_1.CommonErrors.InvalidArgument);
|
|
433
|
-
}
|
|
434
|
-
const command = (0, helpers_1.adaptOptions)({ role: 'createRole' }, {}, role);
|
|
435
|
-
if (writeConcern) {
|
|
436
|
-
command.writeConcern = writeConcern;
|
|
437
|
-
}
|
|
438
|
-
const orderedCmd = { createRole: command.createRole, ...command };
|
|
439
|
-
return await this._runCommand(orderedCmd);
|
|
440
|
-
}
|
|
441
|
-
async updateRole(rolename, roleDoc, writeConcern) {
|
|
442
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, roleDoc], ['string', 'object'], 'Database.updateRole');
|
|
443
|
-
this._emitDatabaseApiCall('updateRole', {});
|
|
444
|
-
const command = (0, helpers_1.adaptOptions)({}, {
|
|
445
|
-
updateRole: rolename,
|
|
446
|
-
}, roleDoc);
|
|
447
|
-
if (writeConcern) {
|
|
448
|
-
command.writeConcern = writeConcern;
|
|
449
|
-
}
|
|
450
|
-
const orderedCmd = { updateRole: command.updateRole, ...command };
|
|
451
|
-
return await this._runCommand(orderedCmd);
|
|
452
|
-
}
|
|
453
|
-
async dropRole(rolename, writeConcern) {
|
|
454
|
-
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.dropRole');
|
|
455
|
-
this._emitDatabaseApiCall('dropRole', {});
|
|
456
|
-
const cmd = { dropRole: rolename };
|
|
457
|
-
if (writeConcern) {
|
|
458
|
-
cmd.writeConcern = writeConcern;
|
|
459
|
-
}
|
|
460
|
-
return await this._runCommand(cmd);
|
|
461
|
-
}
|
|
462
|
-
async dropAllRoles(writeConcern) {
|
|
463
|
-
this._emitDatabaseApiCall('dropAllRoles', {});
|
|
464
|
-
const cmd = { dropAllRolesFromDatabase: 1 };
|
|
465
|
-
if (writeConcern) {
|
|
466
|
-
cmd.writeConcern = writeConcern;
|
|
709
|
+
async fsyncUnlock() {
|
|
710
|
+
this._emitDatabaseApiCall('fsyncUnlock', {});
|
|
711
|
+
return await this._runAdminCommand({
|
|
712
|
+
fsyncUnlock: 1,
|
|
713
|
+
});
|
|
467
714
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return await this._runCommand(cmd);
|
|
478
|
-
}
|
|
479
|
-
async revokeRolesFromRole(rolename, roles, writeConcern) {
|
|
480
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.revokeRolesFromRole');
|
|
481
|
-
this._emitDatabaseApiCall('revokeRolesFromRole', {});
|
|
482
|
-
const cmd = { revokeRolesFromRole: rolename, roles: roles };
|
|
483
|
-
if (writeConcern) {
|
|
484
|
-
cmd.writeConcern = writeConcern;
|
|
485
|
-
}
|
|
486
|
-
return await this._runCommand(cmd);
|
|
487
|
-
}
|
|
488
|
-
async grantPrivilegesToRole(rolename, privileges, writeConcern) {
|
|
489
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.grantPrivilegesToRole');
|
|
490
|
-
this._emitDatabaseApiCall('grantPrivilegesToRole', {});
|
|
491
|
-
const cmd = {
|
|
492
|
-
grantPrivilegesToRole: rolename,
|
|
493
|
-
privileges: privileges,
|
|
494
|
-
};
|
|
495
|
-
if (writeConcern) {
|
|
496
|
-
cmd.writeConcern = writeConcern;
|
|
497
|
-
}
|
|
498
|
-
return await this._runCommand(cmd);
|
|
499
|
-
}
|
|
500
|
-
async revokePrivilegesFromRole(rolename, privileges, writeConcern) {
|
|
501
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.revokePrivilegesFromRole');
|
|
502
|
-
this._emitDatabaseApiCall('revokePrivilegesFromRole', {});
|
|
503
|
-
const cmd = {
|
|
504
|
-
revokePrivilegesFromRole: rolename,
|
|
505
|
-
privileges: privileges,
|
|
506
|
-
};
|
|
507
|
-
if (writeConcern) {
|
|
508
|
-
cmd.writeConcern = writeConcern;
|
|
509
|
-
}
|
|
510
|
-
return await this._runCommand(cmd);
|
|
511
|
-
}
|
|
512
|
-
async getRole(rolename, options = {}) {
|
|
513
|
-
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.getRole');
|
|
514
|
-
this._emitDatabaseApiCall('getRole', { rolename: rolename });
|
|
515
|
-
const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: { role: rolename, db: this._name } }, options);
|
|
516
|
-
const result = await this._runReadCommand(command);
|
|
517
|
-
if (result.roles === undefined) {
|
|
518
|
-
throw new errors_1.MongoshInternalError('No roles returned from rolesInfo command');
|
|
715
|
+
async version() {
|
|
716
|
+
this._emitDatabaseApiCall('version', {});
|
|
717
|
+
const info = await this._runAdminCommand({
|
|
718
|
+
buildInfo: 1,
|
|
719
|
+
});
|
|
720
|
+
if (!info || info.version === undefined) {
|
|
721
|
+
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
722
|
+
}
|
|
723
|
+
return info.version;
|
|
519
724
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
725
|
+
async serverBits() {
|
|
726
|
+
this._emitDatabaseApiCall('serverBits', {});
|
|
727
|
+
const info = await this._runAdminCommand({
|
|
728
|
+
buildInfo: 1,
|
|
729
|
+
});
|
|
730
|
+
if (!info || info.bits === undefined) {
|
|
731
|
+
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
523
732
|
}
|
|
733
|
+
return info.bits;
|
|
524
734
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
for (const filtername of Object.keys(opts)) {
|
|
548
|
-
if (filtername !== '$ownOps' &&
|
|
549
|
-
filtername !== '$all' &&
|
|
550
|
-
filtername !== '$truncateOps') {
|
|
551
|
-
matchingFilters[filtername] = opts[filtername];
|
|
735
|
+
async isMaster() {
|
|
736
|
+
this._emitDatabaseApiCall('isMaster', {});
|
|
737
|
+
const result = await this._runReadCommand({
|
|
738
|
+
isMaster: 1,
|
|
739
|
+
});
|
|
740
|
+
result.isWritablePrimary = result.ismaster;
|
|
741
|
+
return result;
|
|
742
|
+
}
|
|
743
|
+
async hello() {
|
|
744
|
+
this._emitDatabaseApiCall('hello', {});
|
|
745
|
+
try {
|
|
746
|
+
this._cachedHello = await this._runReadCommand({
|
|
747
|
+
hello: 1,
|
|
748
|
+
});
|
|
749
|
+
return this._cachedHello;
|
|
750
|
+
}
|
|
751
|
+
catch (err) {
|
|
752
|
+
if ((err === null || err === void 0 ? void 0 : err.codeName) === 'CommandNotFound') {
|
|
753
|
+
const result = await this.isMaster();
|
|
754
|
+
delete result.ismaster;
|
|
755
|
+
this._cachedHello = result;
|
|
756
|
+
return this._cachedHello;
|
|
552
757
|
}
|
|
758
|
+
throw err;
|
|
553
759
|
}
|
|
554
|
-
pipeline.push({ $match: matchingFilters });
|
|
555
760
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
761
|
+
async serverBuildInfo() {
|
|
762
|
+
this._emitDatabaseApiCall('serverBuildInfo', {});
|
|
763
|
+
return await this._runAdminCommand({
|
|
764
|
+
buildInfo: 1,
|
|
765
|
+
});
|
|
561
766
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
767
|
+
async serverStatus(opts = {}) {
|
|
768
|
+
this._emitDatabaseApiCall('serverStatus', { options: opts });
|
|
769
|
+
return await this._runAdminCommand({
|
|
770
|
+
serverStatus: 1,
|
|
771
|
+
...opts,
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
async stats(scaleOrOptions = 1) {
|
|
775
|
+
(0, helpers_1.assertArgsDefinedType)([scaleOrOptions], [['number', 'object']], 'Database.stats');
|
|
776
|
+
if (typeof scaleOrOptions === 'number') {
|
|
777
|
+
scaleOrOptions = { scale: scaleOrOptions };
|
|
567
778
|
}
|
|
568
|
-
|
|
779
|
+
this._emitDatabaseApiCall('stats', { scale: scaleOrOptions.scale });
|
|
780
|
+
return await this._runReadCommand({
|
|
781
|
+
dbStats: 1,
|
|
782
|
+
scale: 1,
|
|
783
|
+
...scaleOrOptions,
|
|
784
|
+
});
|
|
569
785
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return {
|
|
575
|
-
inprog: currentOps,
|
|
576
|
-
ok: 1,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
async killOp(opId) {
|
|
580
|
-
this._emitDatabaseApiCall('killOp', { opId });
|
|
581
|
-
return await this._runAdminCommand({
|
|
582
|
-
killOp: 1,
|
|
583
|
-
op: opId,
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
async shutdownServer(opts = {}) {
|
|
587
|
-
this._emitDatabaseApiCall('shutdownServer', { opts: opts });
|
|
588
|
-
return await this._runAdminCommand({
|
|
589
|
-
shutdown: 1,
|
|
590
|
-
...opts,
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
async fsyncLock() {
|
|
594
|
-
this._emitDatabaseApiCall('fsyncLock', {});
|
|
595
|
-
return await this._runAdminCommand({
|
|
596
|
-
fsync: 1,
|
|
597
|
-
lock: true,
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
async fsyncUnlock() {
|
|
601
|
-
this._emitDatabaseApiCall('fsyncUnlock', {});
|
|
602
|
-
return await this._runAdminCommand({
|
|
603
|
-
fsyncUnlock: 1,
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
async version() {
|
|
607
|
-
this._emitDatabaseApiCall('version', {});
|
|
608
|
-
const info = await this._runAdminCommand({
|
|
609
|
-
buildInfo: 1,
|
|
610
|
-
});
|
|
611
|
-
if (!info || info.version === undefined) {
|
|
612
|
-
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
613
|
-
}
|
|
614
|
-
return info.version;
|
|
615
|
-
}
|
|
616
|
-
async serverBits() {
|
|
617
|
-
this._emitDatabaseApiCall('serverBits', {});
|
|
618
|
-
const info = await this._runAdminCommand({
|
|
619
|
-
buildInfo: 1,
|
|
620
|
-
});
|
|
621
|
-
if (!info || info.bits === undefined) {
|
|
622
|
-
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
623
|
-
}
|
|
624
|
-
return info.bits;
|
|
625
|
-
}
|
|
626
|
-
async isMaster() {
|
|
627
|
-
this._emitDatabaseApiCall('isMaster', {});
|
|
628
|
-
const result = await this._runReadCommand({
|
|
629
|
-
isMaster: 1,
|
|
630
|
-
});
|
|
631
|
-
result.isWritablePrimary = result.ismaster;
|
|
632
|
-
return result;
|
|
633
|
-
}
|
|
634
|
-
async hello() {
|
|
635
|
-
this._emitDatabaseApiCall('hello', {});
|
|
636
|
-
try {
|
|
637
|
-
this._cachedHello = await this._runReadCommand({
|
|
638
|
-
hello: 1,
|
|
786
|
+
async hostInfo() {
|
|
787
|
+
this._emitDatabaseApiCall('hostInfo', {});
|
|
788
|
+
return await this._runAdminCommand({
|
|
789
|
+
hostInfo: 1,
|
|
639
790
|
});
|
|
640
|
-
return this._cachedHello;
|
|
641
791
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
return this._cachedHello;
|
|
648
|
-
}
|
|
649
|
-
throw err;
|
|
792
|
+
async serverCmdLineOpts() {
|
|
793
|
+
this._emitDatabaseApiCall('serverCmdLineOpts', {});
|
|
794
|
+
return await this._runAdminCommand({
|
|
795
|
+
getCmdLineOpts: 1,
|
|
796
|
+
});
|
|
650
797
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
serverStatus: 1,
|
|
662
|
-
...opts,
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
async stats(scaleOrOptions = 1) {
|
|
666
|
-
(0, helpers_1.assertArgsDefinedType)([scaleOrOptions], [['number', 'object']], 'Database.stats');
|
|
667
|
-
if (typeof scaleOrOptions === 'number') {
|
|
668
|
-
scaleOrOptions = { scale: scaleOrOptions };
|
|
669
|
-
}
|
|
670
|
-
this._emitDatabaseApiCall('stats', { scale: scaleOrOptions.scale });
|
|
671
|
-
return await this._runReadCommand({
|
|
672
|
-
dbStats: 1,
|
|
673
|
-
scale: 1,
|
|
674
|
-
...scaleOrOptions,
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
async hostInfo() {
|
|
678
|
-
this._emitDatabaseApiCall('hostInfo', {});
|
|
679
|
-
return await this._runAdminCommand({
|
|
680
|
-
hostInfo: 1,
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
async serverCmdLineOpts() {
|
|
684
|
-
this._emitDatabaseApiCall('serverCmdLineOpts', {});
|
|
685
|
-
return await this._runAdminCommand({
|
|
686
|
-
getCmdLineOpts: 1,
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
async rotateCertificates(message) {
|
|
690
|
-
this._emitDatabaseApiCall('rotateCertificates', { message });
|
|
691
|
-
return await this._runAdminCommand({
|
|
692
|
-
rotateCertificates: 1,
|
|
693
|
-
message,
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
async printCollectionStats(scale = 1) {
|
|
697
|
-
if (typeof scale !== 'number' || scale < 1) {
|
|
698
|
-
throw new errors_1.MongoshInvalidInputError(`scale has to be a number >=1, got ${scale}`, errors_1.CommonErrors.InvalidArgument);
|
|
699
|
-
}
|
|
700
|
-
this._emitDatabaseApiCall('printCollectionStats', { scale: scale });
|
|
701
|
-
const colls = await this.getCollectionNames();
|
|
702
|
-
const result = {};
|
|
703
|
-
for (const c of colls) {
|
|
704
|
-
try {
|
|
705
|
-
result[c] = await this.getCollection(c).stats({ scale });
|
|
798
|
+
async rotateCertificates(message) {
|
|
799
|
+
this._emitDatabaseApiCall('rotateCertificates', { message });
|
|
800
|
+
return await this._runAdminCommand({
|
|
801
|
+
rotateCertificates: 1,
|
|
802
|
+
message,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
async printCollectionStats(scale = 1) {
|
|
806
|
+
if (typeof scale !== 'number' || scale < 1) {
|
|
807
|
+
throw new errors_1.MongoshInvalidInputError(`scale has to be a number >=1, got ${scale}`, errors_1.CommonErrors.InvalidArgument);
|
|
706
808
|
}
|
|
707
|
-
|
|
708
|
-
|
|
809
|
+
this._emitDatabaseApiCall('printCollectionStats', { scale: scale });
|
|
810
|
+
const colls = await this.getCollectionNames();
|
|
811
|
+
const result = {};
|
|
812
|
+
for (const c of colls) {
|
|
813
|
+
try {
|
|
814
|
+
result[c] = await this.getCollection(c).stats({ scale });
|
|
815
|
+
}
|
|
816
|
+
catch (error) {
|
|
817
|
+
result[c] = { ok: 0, errmsg: error === null || error === void 0 ? void 0 : error.message };
|
|
818
|
+
}
|
|
709
819
|
}
|
|
820
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
710
821
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
profile: -1,
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
async setProfilingLevel(level, opts = {}) {
|
|
720
|
-
(0, helpers_1.assertArgsDefinedType)([level], ['number'], 'Database.setProfilingLevel');
|
|
721
|
-
if (level < 0 || level > 2) {
|
|
722
|
-
throw new errors_1.MongoshInvalidInputError(`Input level ${level} is out of range [0..2]`, errors_1.CommonErrors.InvalidArgument);
|
|
723
|
-
}
|
|
724
|
-
if (typeof opts === 'number') {
|
|
725
|
-
opts = { slowms: opts };
|
|
726
|
-
}
|
|
727
|
-
this._emitDatabaseApiCall('setProfilingLevel', { opts: opts });
|
|
728
|
-
return await this._runCommand({
|
|
729
|
-
profile: level,
|
|
730
|
-
...opts,
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
async setLogLevel(logLevel, component) {
|
|
734
|
-
(0, helpers_1.assertArgsDefinedType)([logLevel], ['number'], 'Database.setLogLevel');
|
|
735
|
-
this._emitDatabaseApiCall('setLogLevel', {
|
|
736
|
-
logLevel: logLevel,
|
|
737
|
-
component: component,
|
|
738
|
-
});
|
|
739
|
-
let componentNames = [];
|
|
740
|
-
if (typeof component === 'string') {
|
|
741
|
-
componentNames = component.split('.');
|
|
742
|
-
}
|
|
743
|
-
else if (component !== undefined) {
|
|
744
|
-
throw new errors_1.MongoshInvalidInputError(`setLogLevel component must be a string: got ${typeof component}`, errors_1.CommonErrors.InvalidArgument);
|
|
745
|
-
}
|
|
746
|
-
let vDoc = { verbosity: logLevel };
|
|
747
|
-
while (componentNames.length > 0) {
|
|
748
|
-
const key = componentNames.pop();
|
|
749
|
-
vDoc = { [key]: vDoc };
|
|
750
|
-
}
|
|
751
|
-
const cmdObj = { setParameter: 1, logComponentVerbosity: vDoc };
|
|
752
|
-
return await this._runAdminCommand(cmdObj);
|
|
753
|
-
}
|
|
754
|
-
async getLogComponents() {
|
|
755
|
-
this._emitDatabaseApiCall('getLogComponents', {});
|
|
756
|
-
const cmdObj = { getParameter: 1, logComponentVerbosity: 1 };
|
|
757
|
-
const result = await this._runAdminCommand(cmdObj);
|
|
758
|
-
if (!result || result.logComponentVerbosity === undefined) {
|
|
759
|
-
throw new errors_1.MongoshRuntimeError(`Error running command ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
760
|
-
}
|
|
761
|
-
return result.logComponentVerbosity;
|
|
762
|
-
}
|
|
763
|
-
cloneDatabase() {
|
|
764
|
-
throw new errors_1.MongoshDeprecatedError('`cloneDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
765
|
-
}
|
|
766
|
-
cloneCollection() {
|
|
767
|
-
throw new errors_1.MongoshDeprecatedError('`cloneCollection()` was removed because it was deprecated in MongoDB 4.0');
|
|
768
|
-
}
|
|
769
|
-
copyDatabase() {
|
|
770
|
-
throw new errors_1.MongoshDeprecatedError('`copyDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
771
|
-
}
|
|
772
|
-
async commandHelp(name) {
|
|
773
|
-
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.commandHelp');
|
|
774
|
-
this._emitDatabaseApiCall('commandHelp', { name: name });
|
|
775
|
-
const command = {};
|
|
776
|
-
command[name] = 1;
|
|
777
|
-
command.help = true;
|
|
778
|
-
const result = await this._runCommand(command);
|
|
779
|
-
if (!result || result.help === undefined) {
|
|
780
|
-
throw new errors_1.MongoshRuntimeError(`Error running command commandHelp ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
781
|
-
}
|
|
782
|
-
return result.help;
|
|
783
|
-
}
|
|
784
|
-
async listCommands() {
|
|
785
|
-
this._emitDatabaseApiCall('listCommands', {});
|
|
786
|
-
const result = await this._runReadCommand({
|
|
787
|
-
listCommands: 1,
|
|
788
|
-
});
|
|
789
|
-
if (!result || result.commands === undefined) {
|
|
790
|
-
throw new errors_1.MongoshRuntimeError(`Error running command listCommands ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
822
|
+
async getProfilingStatus() {
|
|
823
|
+
this._emitDatabaseApiCall('getProfilingStatus', {});
|
|
824
|
+
return await this._runReadCommand({
|
|
825
|
+
profile: -1,
|
|
826
|
+
});
|
|
791
827
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
828
|
+
async setProfilingLevel(level, opts = {}) {
|
|
829
|
+
(0, helpers_1.assertArgsDefinedType)([level], ['number'], 'Database.setProfilingLevel');
|
|
830
|
+
if (level < 0 || level > 2) {
|
|
831
|
+
throw new errors_1.MongoshInvalidInputError(`Input level ${level} is out of range [0..2]`, errors_1.CommonErrors.InvalidArgument);
|
|
796
832
|
}
|
|
797
|
-
if ('
|
|
798
|
-
|
|
799
|
-
delete cmdDescription.slaveOverrideOk;
|
|
833
|
+
if (typeof opts === 'number') {
|
|
834
|
+
opts = { slowms: opts };
|
|
800
835
|
}
|
|
836
|
+
this._emitDatabaseApiCall('setProfilingLevel', { opts: opts });
|
|
837
|
+
return await this._runCommand({
|
|
838
|
+
profile: level,
|
|
839
|
+
...opts,
|
|
840
|
+
});
|
|
801
841
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
return await this._getLastErrorObj(w, wTimeout, j);
|
|
812
|
-
}
|
|
813
|
-
async getLastError(w, wTimeout) {
|
|
814
|
-
await this._instanceState.printDeprecationWarning('Database.getLastError() is deprecated and will be removed in the future.');
|
|
815
|
-
this._emitDatabaseApiCall('getLastError', { w: w, wTimeout: wTimeout });
|
|
816
|
-
const result = await this._getLastErrorObj(w, wTimeout);
|
|
817
|
-
return result.err || null;
|
|
818
|
-
}
|
|
819
|
-
async printShardingStatus(verbose = false) {
|
|
820
|
-
this._emitDatabaseApiCall('printShardingStatus', { verbose });
|
|
821
|
-
const result = await (0, helpers_1.getPrintableShardStatus)(await (0, helpers_1.getConfigDB)(this), verbose);
|
|
822
|
-
return new index_1.CommandResult('StatsResult', result);
|
|
823
|
-
}
|
|
824
|
-
async printSecondaryReplicationInfo() {
|
|
825
|
-
let startOptimeDate = null;
|
|
826
|
-
const local = this.getSiblingDB('local');
|
|
827
|
-
if ((await local.getCollection('system.replset').countDocuments({})) !== 0) {
|
|
828
|
-
const status = await this._runAdminCommand({ replSetGetStatus: 1 });
|
|
829
|
-
let primary = null;
|
|
830
|
-
for (const member of status.members) {
|
|
831
|
-
if (member.state === 1) {
|
|
832
|
-
primary = member;
|
|
833
|
-
break;
|
|
834
|
-
}
|
|
842
|
+
async setLogLevel(logLevel, component) {
|
|
843
|
+
(0, helpers_1.assertArgsDefinedType)([logLevel], ['number'], 'Database.setLogLevel');
|
|
844
|
+
this._emitDatabaseApiCall('setLogLevel', {
|
|
845
|
+
logLevel: logLevel,
|
|
846
|
+
component: component,
|
|
847
|
+
});
|
|
848
|
+
let componentNames = [];
|
|
849
|
+
if (typeof component === 'string') {
|
|
850
|
+
componentNames = component.split('.');
|
|
835
851
|
}
|
|
836
|
-
if (
|
|
837
|
-
|
|
852
|
+
else if (component !== undefined) {
|
|
853
|
+
throw new errors_1.MongoshInvalidInputError(`setLogLevel component must be a string: got ${typeof component}`, errors_1.CommonErrors.InvalidArgument);
|
|
838
854
|
}
|
|
839
|
-
|
|
840
|
-
|
|
855
|
+
let vDoc = { verbosity: logLevel };
|
|
856
|
+
while (componentNames.length > 0) {
|
|
857
|
+
const key = componentNames.pop();
|
|
858
|
+
vDoc = { [key]: vDoc };
|
|
859
|
+
}
|
|
860
|
+
const cmdObj = { setParameter: 1, logComponentVerbosity: vDoc };
|
|
861
|
+
return await this._runAdminCommand(cmdObj);
|
|
862
|
+
}
|
|
863
|
+
async getLogComponents() {
|
|
864
|
+
this._emitDatabaseApiCall('getLogComponents', {});
|
|
865
|
+
const cmdObj = { getParameter: 1, logComponentVerbosity: 1 };
|
|
866
|
+
const result = await this._runAdminCommand(cmdObj);
|
|
867
|
+
if (!result || result.logComponentVerbosity === undefined) {
|
|
868
|
+
throw new errors_1.MongoshRuntimeError(`Error running command ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
869
|
+
}
|
|
870
|
+
return result.logComponentVerbosity;
|
|
871
|
+
}
|
|
872
|
+
cloneDatabase() {
|
|
873
|
+
throw new errors_1.MongoshDeprecatedError('`cloneDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
874
|
+
}
|
|
875
|
+
cloneCollection() {
|
|
876
|
+
throw new errors_1.MongoshDeprecatedError('`cloneCollection()` was removed because it was deprecated in MongoDB 4.0');
|
|
877
|
+
}
|
|
878
|
+
copyDatabase() {
|
|
879
|
+
throw new errors_1.MongoshDeprecatedError('`copyDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
880
|
+
}
|
|
881
|
+
async commandHelp(name) {
|
|
882
|
+
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.commandHelp');
|
|
883
|
+
this._emitDatabaseApiCall('commandHelp', { name: name });
|
|
884
|
+
const command = {};
|
|
885
|
+
command[name] = 1;
|
|
886
|
+
command.help = true;
|
|
887
|
+
const result = await this._runCommand(command);
|
|
888
|
+
if (!result || result.help === undefined) {
|
|
889
|
+
throw new errors_1.MongoshRuntimeError(`Error running command commandHelp ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
890
|
+
}
|
|
891
|
+
return result.help;
|
|
892
|
+
}
|
|
893
|
+
async listCommands() {
|
|
894
|
+
this._emitDatabaseApiCall('listCommands', {});
|
|
895
|
+
const result = await this._runReadCommand({
|
|
896
|
+
listCommands: 1,
|
|
897
|
+
});
|
|
898
|
+
if (!result || result.commands === undefined) {
|
|
899
|
+
throw new errors_1.MongoshRuntimeError(`Error running command listCommands ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
900
|
+
}
|
|
901
|
+
for (const cmdDescription of Object.values(result.commands)) {
|
|
902
|
+
if ('slaveOk' in cmdDescription) {
|
|
903
|
+
cmdDescription.secondaryOk = cmdDescription.slaveOk;
|
|
904
|
+
delete cmdDescription.slaveOk;
|
|
905
|
+
}
|
|
906
|
+
if ('slaveOverrideOk' in cmdDescription) {
|
|
907
|
+
cmdDescription.secondaryOverrideOk = cmdDescription.slaveOverrideOk;
|
|
908
|
+
delete cmdDescription.slaveOverrideOk;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return new index_1.CommandResult('ListCommandsResult', result.commands);
|
|
912
|
+
}
|
|
913
|
+
async getLastErrorObj(w, wTimeout, j) {
|
|
914
|
+
await this._instanceState.printDeprecationWarning('Database.getLastErrorObj() is deprecated and will be removed in the future.');
|
|
915
|
+
this._emitDatabaseApiCall('getLastErrorObj', {
|
|
916
|
+
w: w,
|
|
917
|
+
wTimeout: wTimeout,
|
|
918
|
+
j: j,
|
|
919
|
+
});
|
|
920
|
+
return await this._getLastErrorObj(w, wTimeout, j);
|
|
921
|
+
}
|
|
922
|
+
async getLastError(w, wTimeout) {
|
|
923
|
+
await this._instanceState.printDeprecationWarning('Database.getLastError() is deprecated and will be removed in the future.');
|
|
924
|
+
this._emitDatabaseApiCall('getLastError', { w: w, wTimeout: wTimeout });
|
|
925
|
+
const result = await this._getLastErrorObj(w, wTimeout);
|
|
926
|
+
return result.err || null;
|
|
927
|
+
}
|
|
928
|
+
async printShardingStatus(verbose = false) {
|
|
929
|
+
this._emitDatabaseApiCall('printShardingStatus', { verbose });
|
|
930
|
+
const result = await (0, helpers_1.getPrintableShardStatus)(await (0, helpers_1.getConfigDB)(this), verbose);
|
|
931
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
932
|
+
}
|
|
933
|
+
async printSecondaryReplicationInfo() {
|
|
934
|
+
let startOptimeDate = null;
|
|
935
|
+
const local = this.getSiblingDB('local');
|
|
936
|
+
if ((await local.getCollection('system.replset').countDocuments({})) !== 0) {
|
|
937
|
+
const status = await this._runAdminCommand({ replSetGetStatus: 1 });
|
|
938
|
+
let primary = null;
|
|
841
939
|
for (const member of status.members) {
|
|
842
|
-
if (member.
|
|
843
|
-
|
|
940
|
+
if (member.state === 1) {
|
|
941
|
+
primary = member;
|
|
942
|
+
break;
|
|
844
943
|
}
|
|
845
944
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
for (const node of status.members) {
|
|
849
|
-
const nodeResult = {};
|
|
850
|
-
if (node === null || node === undefined) {
|
|
851
|
-
throw new errors_1.MongoshRuntimeError('Member returned from command replSetGetStatus is null', errors_1.CommonErrors.CommandFailed);
|
|
945
|
+
if (primary) {
|
|
946
|
+
startOptimeDate = primary.optimeDate;
|
|
852
947
|
}
|
|
853
|
-
|
|
854
|
-
|
|
948
|
+
else {
|
|
949
|
+
startOptimeDate = new Date(0, 0);
|
|
950
|
+
for (const member of status.members) {
|
|
951
|
+
if (member.optimeDate > startOptimeDate) {
|
|
952
|
+
startOptimeDate = member.optimeDate;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
855
955
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
956
|
+
const result = {};
|
|
957
|
+
for (const node of status.members) {
|
|
958
|
+
const nodeResult = {};
|
|
959
|
+
if (node === null || node === undefined) {
|
|
960
|
+
throw new errors_1.MongoshRuntimeError('Member returned from command replSetGetStatus is null', errors_1.CommonErrors.CommandFailed);
|
|
859
961
|
}
|
|
860
|
-
if (
|
|
861
|
-
|
|
962
|
+
if (node.state === 1 || node.state === 7) {
|
|
963
|
+
continue;
|
|
862
964
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
965
|
+
if (node.optime && node.health !== 0) {
|
|
966
|
+
if (startOptimeDate === null || startOptimeDate === undefined) {
|
|
967
|
+
throw new errors_1.MongoshRuntimeError('getReplLag startOptimeDate is null', errors_1.CommonErrors.CommandFailed);
|
|
968
|
+
}
|
|
969
|
+
if (startOptimeDate) {
|
|
970
|
+
nodeResult.syncedTo = node.optimeDate.toString();
|
|
971
|
+
}
|
|
972
|
+
const ago = (node.optimeDate - startOptimeDate) / 1000;
|
|
973
|
+
const hrs = Math.round(ago / 36) / 100;
|
|
974
|
+
let suffix = '';
|
|
975
|
+
if (primary) {
|
|
976
|
+
suffix = 'primary ';
|
|
977
|
+
}
|
|
978
|
+
else {
|
|
979
|
+
suffix = 'freshest member (no primary available at the moment)';
|
|
980
|
+
}
|
|
981
|
+
nodeResult.replLag = `${Math.round(ago)} secs (${hrs} hrs) behind the ${suffix}`;
|
|
868
982
|
}
|
|
869
983
|
else {
|
|
870
|
-
|
|
984
|
+
nodeResult['no replication info, yet. State'] = node.stateStr;
|
|
871
985
|
}
|
|
872
|
-
|
|
986
|
+
result[`source: ${node.name}`] = nodeResult;
|
|
873
987
|
}
|
|
874
|
-
|
|
875
|
-
|
|
988
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
989
|
+
}
|
|
990
|
+
throw new errors_1.MongoshInvalidInputError('local.system.replset is empty. Are you connected to a replica set?', error_codes_1.ShellApiErrors.NotConnectedToReplicaSet);
|
|
991
|
+
}
|
|
992
|
+
async getReplicationInfo() {
|
|
993
|
+
const localdb = this.getSiblingDB('local');
|
|
994
|
+
const result = {};
|
|
995
|
+
const oplog = 'oplog.rs';
|
|
996
|
+
const localCollections = await localdb.getCollectionNames();
|
|
997
|
+
if (!localCollections.includes(oplog)) {
|
|
998
|
+
throw new errors_1.MongoshInvalidInputError('Replication not detected. Are you connected to a replset?', error_codes_1.ShellApiErrors.NotConnectedToReplicaSet);
|
|
999
|
+
}
|
|
1000
|
+
const ol = localdb.getCollection(oplog);
|
|
1001
|
+
const [olStats, first, last] = await Promise.all([
|
|
1002
|
+
ol.stats(),
|
|
1003
|
+
(async () => (await ol.find()).sort({ $natural: 1 }).limit(1).tryNext())(),
|
|
1004
|
+
(async () => (await ol.find()).sort({ $natural: -1 }).limit(1).tryNext())(),
|
|
1005
|
+
]);
|
|
1006
|
+
if (!(olStats === null || olStats === void 0 ? void 0 : olStats.maxSize)) {
|
|
1007
|
+
throw new errors_1.MongoshRuntimeError(`Could not get stats for local.${oplog} collection. collstats returned ${JSON.stringify(olStats)}`, errors_1.CommonErrors.CommandFailed);
|
|
1008
|
+
}
|
|
1009
|
+
result.configuredLogSizeMB = olStats.maxSize / (1024 * 1024);
|
|
1010
|
+
result.logSizeMB = Math.max(olStats.maxSize, olStats.size) / (1024 * 1024);
|
|
1011
|
+
result.usedMB = olStats.size / (1024 * 1024);
|
|
1012
|
+
result.usedMB = Math.ceil(result.usedMB * 100) / 100;
|
|
1013
|
+
if (first === null || last === null) {
|
|
1014
|
+
throw new errors_1.MongoshRuntimeError('objects not found in local.oplog.$main -- is this a new and empty db instance?', errors_1.CommonErrors.CommandFailed);
|
|
1015
|
+
}
|
|
1016
|
+
let tfirst = first.ts;
|
|
1017
|
+
let tlast = last.ts;
|
|
1018
|
+
if (tfirst && tlast) {
|
|
1019
|
+
tfirst = (0, helpers_1.tsToSeconds)(tfirst);
|
|
1020
|
+
tlast = (0, helpers_1.tsToSeconds)(tlast);
|
|
1021
|
+
result.timeDiff = tlast - tfirst;
|
|
1022
|
+
result.timeDiffHours = Math.round(result.timeDiff / 36) / 100;
|
|
1023
|
+
result.tFirst = new Date(tfirst * 1000).toString();
|
|
1024
|
+
result.tLast = new Date(tlast * 1000).toString();
|
|
1025
|
+
result.now = Date();
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
result.errmsg = 'ts element not found in oplog objects';
|
|
1029
|
+
}
|
|
1030
|
+
return result;
|
|
1031
|
+
}
|
|
1032
|
+
async printReplicationInfo() {
|
|
1033
|
+
const result = {};
|
|
1034
|
+
let replInfo;
|
|
1035
|
+
try {
|
|
1036
|
+
replInfo = await this.getReplicationInfo();
|
|
1037
|
+
}
|
|
1038
|
+
catch (error) {
|
|
1039
|
+
const helloResult = await this.hello();
|
|
1040
|
+
if (helloResult.arbiterOnly) {
|
|
1041
|
+
return new index_1.CommandResult('StatsResult', {
|
|
1042
|
+
message: 'cannot provide replication status from an arbiter',
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
else if (!helloResult.isWritablePrimary) {
|
|
1046
|
+
const secondaryInfo = await this.printSecondaryReplicationInfo();
|
|
1047
|
+
return new index_1.CommandResult('StatsResult', {
|
|
1048
|
+
message: 'this is a secondary, printing secondary replication info.',
|
|
1049
|
+
...secondaryInfo.value,
|
|
1050
|
+
});
|
|
876
1051
|
}
|
|
877
|
-
|
|
1052
|
+
throw error;
|
|
878
1053
|
}
|
|
1054
|
+
result['actual oplog size'] = `${replInfo.logSizeMB} MB`;
|
|
1055
|
+
result['configured oplog size'] = `${replInfo.configuredLogSizeMB} MB`;
|
|
1056
|
+
result['log length start to end'] = `${replInfo.timeDiff} secs (${replInfo.timeDiffHours} hrs)`;
|
|
1057
|
+
result['oplog first event time'] = replInfo.tFirst;
|
|
1058
|
+
result['oplog last event time'] = replInfo.tLast;
|
|
1059
|
+
result.now = replInfo.now;
|
|
879
1060
|
return new index_1.CommandResult('StatsResult', result);
|
|
880
1061
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const ol = localdb.getCollection(oplog);
|
|
892
|
-
const [olStats, first, last] = await Promise.all([
|
|
893
|
-
ol.stats(),
|
|
894
|
-
(async () => (await ol.find()).sort({ $natural: 1 }).limit(1).tryNext())(),
|
|
895
|
-
(async () => (await ol.find()).sort({ $natural: -1 }).limit(1).tryNext())(),
|
|
896
|
-
]);
|
|
897
|
-
if (!(olStats === null || olStats === void 0 ? void 0 : olStats.maxSize)) {
|
|
898
|
-
throw new errors_1.MongoshRuntimeError(`Could not get stats for local.${oplog} collection. collstats returned ${JSON.stringify(olStats)}`, errors_1.CommonErrors.CommandFailed);
|
|
899
|
-
}
|
|
900
|
-
result.configuredLogSizeMB = olStats.maxSize / (1024 * 1024);
|
|
901
|
-
result.logSizeMB = Math.max(olStats.maxSize, olStats.size) / (1024 * 1024);
|
|
902
|
-
result.usedMB = olStats.size / (1024 * 1024);
|
|
903
|
-
result.usedMB = Math.ceil(result.usedMB * 100) / 100;
|
|
904
|
-
if (first === null || last === null) {
|
|
905
|
-
throw new errors_1.MongoshRuntimeError('objects not found in local.oplog.$main -- is this a new and empty db instance?', errors_1.CommonErrors.CommandFailed);
|
|
906
|
-
}
|
|
907
|
-
let tfirst = first.ts;
|
|
908
|
-
let tlast = last.ts;
|
|
909
|
-
if (tfirst && tlast) {
|
|
910
|
-
tfirst = (0, helpers_1.tsToSeconds)(tfirst);
|
|
911
|
-
tlast = (0, helpers_1.tsToSeconds)(tlast);
|
|
912
|
-
result.timeDiff = tlast - tfirst;
|
|
913
|
-
result.timeDiffHours = Math.round(result.timeDiff / 36) / 100;
|
|
914
|
-
result.tFirst = new Date(tfirst * 1000).toString();
|
|
915
|
-
result.tLast = new Date(tlast * 1000).toString();
|
|
916
|
-
result.now = Date();
|
|
917
|
-
}
|
|
918
|
-
else {
|
|
919
|
-
result.errmsg = 'ts element not found in oplog objects';
|
|
920
|
-
}
|
|
921
|
-
return result;
|
|
922
|
-
}
|
|
923
|
-
async printReplicationInfo() {
|
|
924
|
-
const result = {};
|
|
925
|
-
let replInfo;
|
|
926
|
-
try {
|
|
927
|
-
replInfo = await this.getReplicationInfo();
|
|
928
|
-
}
|
|
929
|
-
catch (error) {
|
|
930
|
-
const helloResult = await this.hello();
|
|
931
|
-
if (helloResult.arbiterOnly) {
|
|
932
|
-
return new index_1.CommandResult('StatsResult', {
|
|
933
|
-
message: 'cannot provide replication status from an arbiter',
|
|
934
|
-
});
|
|
1062
|
+
printSlaveReplicationInfo() {
|
|
1063
|
+
throw new errors_1.MongoshDeprecatedError('Method deprecated, use db.printSecondaryReplicationInfo instead');
|
|
1064
|
+
}
|
|
1065
|
+
async setSecondaryOk() {
|
|
1066
|
+
await this._mongo.setSecondaryOk();
|
|
1067
|
+
}
|
|
1068
|
+
async watch(pipeline = [], options = {}) {
|
|
1069
|
+
if (!Array.isArray(pipeline)) {
|
|
1070
|
+
options = pipeline;
|
|
1071
|
+
pipeline = [];
|
|
935
1072
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1073
|
+
this._emitDatabaseApiCall('watch', { pipeline, options });
|
|
1074
|
+
const cursor = new change_stream_cursor_1.default(this._mongo._serviceProvider.watch(pipeline, {
|
|
1075
|
+
...(await this._baseOptions()),
|
|
1076
|
+
...options,
|
|
1077
|
+
}, {}, this._name), this._name, this._mongo);
|
|
1078
|
+
if (!options.resumeAfter &&
|
|
1079
|
+
!options.startAfter &&
|
|
1080
|
+
!options.startAtOperationTime) {
|
|
1081
|
+
await cursor.tryNext();
|
|
942
1082
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
async watch(pipeline = [], options = {}) {
|
|
960
|
-
if (!Array.isArray(pipeline)) {
|
|
961
|
-
options = pipeline;
|
|
962
|
-
pipeline = [];
|
|
963
|
-
}
|
|
964
|
-
this._emitDatabaseApiCall('watch', { pipeline, options });
|
|
965
|
-
const cursor = new change_stream_cursor_1.default(this._mongo._serviceProvider.watch(pipeline, {
|
|
966
|
-
...(await this._baseOptions()),
|
|
967
|
-
...options,
|
|
968
|
-
}, {}, this._name), this._name, this._mongo);
|
|
969
|
-
if (!options.resumeAfter &&
|
|
970
|
-
!options.startAfter &&
|
|
971
|
-
!options.startAtOperationTime) {
|
|
972
|
-
await cursor.tryNext();
|
|
973
|
-
}
|
|
974
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
975
|
-
return cursor;
|
|
976
|
-
}
|
|
977
|
-
async sql(sqlString, options) {
|
|
978
|
-
var _a;
|
|
979
|
-
this._emitDatabaseApiCall('sql', { sqlString: sqlString, options });
|
|
980
|
-
await this._instanceState.shellApi.print('Note: this is an experimental feature that may be subject to change in future releases.');
|
|
981
|
-
const cursor = await this.aggregate([
|
|
982
|
-
{
|
|
983
|
-
$sql: {
|
|
984
|
-
statement: sqlString,
|
|
985
|
-
format: 'jdbc',
|
|
986
|
-
dialect: 'mongosql',
|
|
987
|
-
formatVersion: 1,
|
|
1083
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
1084
|
+
return cursor;
|
|
1085
|
+
}
|
|
1086
|
+
async sql(sqlString, options) {
|
|
1087
|
+
var _a;
|
|
1088
|
+
this._emitDatabaseApiCall('sql', { sqlString: sqlString, options });
|
|
1089
|
+
await this._instanceState.shellApi.print('Note: this is an experimental feature that may be subject to change in future releases.');
|
|
1090
|
+
const cursor = await this.aggregate([
|
|
1091
|
+
{
|
|
1092
|
+
$sql: {
|
|
1093
|
+
statement: sqlString,
|
|
1094
|
+
format: 'jdbc',
|
|
1095
|
+
dialect: 'mongosql',
|
|
1096
|
+
formatVersion: 1,
|
|
1097
|
+
},
|
|
988
1098
|
},
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
await cursor.hasNext();
|
|
993
|
-
}
|
|
994
|
-
catch (err) {
|
|
995
|
-
if (((_a = err.code) === null || _a === void 0 ? void 0 : _a.valueOf()) === 40324) {
|
|
996
|
-
throw new errors_1.MongoshRuntimeError('db.sql currently only works when connected to a Data Lake', errors_1.CommonErrors.CommandFailed);
|
|
1099
|
+
], options);
|
|
1100
|
+
try {
|
|
1101
|
+
await cursor.hasNext();
|
|
997
1102
|
}
|
|
998
|
-
|
|
1103
|
+
catch (err) {
|
|
1104
|
+
if (((_a = err.code) === null || _a === void 0 ? void 0 : _a.valueOf()) === 40324) {
|
|
1105
|
+
throw new errors_1.MongoshRuntimeError('db.sql currently only works when connected to a Data Lake', errors_1.CommonErrors.CommandFailed);
|
|
1106
|
+
}
|
|
1107
|
+
throw err;
|
|
1108
|
+
}
|
|
1109
|
+
return cursor;
|
|
999
1110
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
],
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
], Database.prototype, "fsyncUnlock", null);
|
|
1157
|
-
__decorate([
|
|
1158
|
-
decorators_1.returnsPromise,
|
|
1159
|
-
(0, decorators_1.apiVersions)([])
|
|
1160
|
-
], Database.prototype, "version", null);
|
|
1161
|
-
__decorate([
|
|
1162
|
-
decorators_1.returnsPromise,
|
|
1163
|
-
(0, decorators_1.apiVersions)([])
|
|
1164
|
-
], Database.prototype, "serverBits", null);
|
|
1165
|
-
__decorate([
|
|
1166
|
-
decorators_1.returnsPromise,
|
|
1167
|
-
(0, decorators_1.apiVersions)([])
|
|
1168
|
-
], Database.prototype, "isMaster", null);
|
|
1169
|
-
__decorate([
|
|
1170
|
-
decorators_1.returnsPromise,
|
|
1171
|
-
(0, decorators_1.apiVersions)([1]),
|
|
1172
|
-
(0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])
|
|
1173
|
-
], Database.prototype, "hello", null);
|
|
1174
|
-
__decorate([
|
|
1175
|
-
decorators_1.returnsPromise,
|
|
1176
|
-
(0, decorators_1.apiVersions)([])
|
|
1177
|
-
], Database.prototype, "serverBuildInfo", null);
|
|
1178
|
-
__decorate([
|
|
1179
|
-
decorators_1.returnsPromise,
|
|
1180
|
-
(0, decorators_1.apiVersions)([])
|
|
1181
|
-
], Database.prototype, "serverStatus", null);
|
|
1182
|
-
__decorate([
|
|
1183
|
-
decorators_1.returnsPromise,
|
|
1184
|
-
(0, decorators_1.apiVersions)([])
|
|
1185
|
-
], Database.prototype, "stats", null);
|
|
1186
|
-
__decorate([
|
|
1187
|
-
decorators_1.returnsPromise,
|
|
1188
|
-
(0, decorators_1.apiVersions)([])
|
|
1189
|
-
], Database.prototype, "hostInfo", null);
|
|
1190
|
-
__decorate([
|
|
1191
|
-
decorators_1.returnsPromise,
|
|
1192
|
-
(0, decorators_1.apiVersions)([])
|
|
1193
|
-
], Database.prototype, "serverCmdLineOpts", null);
|
|
1194
|
-
__decorate([
|
|
1195
|
-
decorators_1.returnsPromise,
|
|
1196
|
-
(0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest]),
|
|
1197
|
-
(0, decorators_1.apiVersions)([])
|
|
1198
|
-
], Database.prototype, "rotateCertificates", null);
|
|
1199
|
-
__decorate([
|
|
1200
|
-
decorators_1.returnsPromise,
|
|
1201
|
-
(0, decorators_1.apiVersions)([])
|
|
1202
|
-
], Database.prototype, "printCollectionStats", null);
|
|
1203
|
-
__decorate([
|
|
1204
|
-
decorators_1.returnsPromise,
|
|
1205
|
-
(0, decorators_1.apiVersions)([])
|
|
1206
|
-
], Database.prototype, "getProfilingStatus", null);
|
|
1207
|
-
__decorate([
|
|
1208
|
-
decorators_1.returnsPromise,
|
|
1209
|
-
(0, decorators_1.apiVersions)([])
|
|
1210
|
-
], Database.prototype, "setProfilingLevel", null);
|
|
1211
|
-
__decorate([
|
|
1212
|
-
decorators_1.returnsPromise,
|
|
1213
|
-
(0, decorators_1.apiVersions)([])
|
|
1214
|
-
], Database.prototype, "setLogLevel", null);
|
|
1215
|
-
__decorate([
|
|
1216
|
-
decorators_1.returnsPromise,
|
|
1217
|
-
(0, decorators_1.apiVersions)([])
|
|
1218
|
-
], Database.prototype, "getLogComponents", null);
|
|
1219
|
-
__decorate([
|
|
1220
|
-
decorators_1.deprecated
|
|
1221
|
-
], Database.prototype, "cloneDatabase", null);
|
|
1222
|
-
__decorate([
|
|
1223
|
-
decorators_1.deprecated
|
|
1224
|
-
], Database.prototype, "cloneCollection", null);
|
|
1225
|
-
__decorate([
|
|
1226
|
-
decorators_1.deprecated
|
|
1227
|
-
], Database.prototype, "copyDatabase", null);
|
|
1228
|
-
__decorate([
|
|
1229
|
-
decorators_1.returnsPromise,
|
|
1230
|
-
(0, decorators_1.apiVersions)([1])
|
|
1231
|
-
], Database.prototype, "commandHelp", null);
|
|
1232
|
-
__decorate([
|
|
1233
|
-
decorators_1.returnsPromise,
|
|
1234
|
-
(0, decorators_1.apiVersions)([])
|
|
1235
|
-
], Database.prototype, "listCommands", null);
|
|
1236
|
-
__decorate([
|
|
1237
|
-
(0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '5.1.0']),
|
|
1238
|
-
decorators_1.deprecated,
|
|
1239
|
-
decorators_1.returnsPromise,
|
|
1240
|
-
(0, decorators_1.apiVersions)([])
|
|
1241
|
-
], Database.prototype, "getLastErrorObj", null);
|
|
1242
|
-
__decorate([
|
|
1243
|
-
decorators_1.deprecated,
|
|
1244
|
-
decorators_1.returnsPromise,
|
|
1245
|
-
(0, decorators_1.apiVersions)([])
|
|
1246
|
-
], Database.prototype, "getLastError", null);
|
|
1247
|
-
__decorate([
|
|
1248
|
-
decorators_1.returnsPromise,
|
|
1249
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1250
|
-
(0, decorators_1.apiVersions)([1])
|
|
1251
|
-
], Database.prototype, "printShardingStatus", null);
|
|
1252
|
-
__decorate([
|
|
1253
|
-
decorators_1.returnsPromise,
|
|
1254
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet]),
|
|
1255
|
-
(0, decorators_1.apiVersions)([])
|
|
1256
|
-
], Database.prototype, "printSecondaryReplicationInfo", null);
|
|
1257
|
-
__decorate([
|
|
1258
|
-
decorators_1.returnsPromise,
|
|
1259
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet]),
|
|
1260
|
-
(0, decorators_1.apiVersions)([])
|
|
1261
|
-
], Database.prototype, "getReplicationInfo", null);
|
|
1262
|
-
__decorate([
|
|
1263
|
-
decorators_1.returnsPromise,
|
|
1264
|
-
(0, decorators_1.apiVersions)([]),
|
|
1265
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet])
|
|
1266
|
-
], Database.prototype, "printReplicationInfo", null);
|
|
1267
|
-
__decorate([
|
|
1268
|
-
decorators_1.deprecated
|
|
1269
|
-
], Database.prototype, "printSlaveReplicationInfo", null);
|
|
1270
|
-
__decorate([
|
|
1271
|
-
decorators_1.deprecated,
|
|
1272
|
-
decorators_1.returnsPromise
|
|
1273
|
-
], Database.prototype, "setSecondaryOk", null);
|
|
1274
|
-
__decorate([
|
|
1275
|
-
(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]),
|
|
1276
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
|
|
1277
|
-
(0, decorators_1.apiVersions)([1]),
|
|
1278
|
-
decorators_1.returnsPromise
|
|
1279
|
-
], Database.prototype, "watch", null);
|
|
1280
|
-
__decorate([
|
|
1281
|
-
(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
|
|
1282
|
-
decorators_1.returnsPromise,
|
|
1283
|
-
(0, decorators_1.returnType)('AggregationCursor')
|
|
1284
|
-
], Database.prototype, "sql", null);
|
|
1285
|
-
__decorate([
|
|
1286
|
-
(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]),
|
|
1287
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1288
|
-
decorators_1.returnsPromise
|
|
1289
|
-
], Database.prototype, "checkMetadataConsistency", null);
|
|
1290
|
-
Database = __decorate([
|
|
1291
|
-
decorators_1.shellApiClassDefault
|
|
1292
|
-
], Database);
|
|
1111
|
+
async checkMetadataConsistency(options = {}) {
|
|
1112
|
+
this._emitDatabaseApiCall('checkMetadataConsistency', { options });
|
|
1113
|
+
return this._runCursorCommand({
|
|
1114
|
+
checkMetadataConsistency: 1,
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
__setFunctionName(_classThis, "Database");
|
|
1119
|
+
(() => {
|
|
1120
|
+
var _a;
|
|
1121
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
1122
|
+
_getMongo_decorators = [(0, decorators_1.returnType)('Mongo')];
|
|
1123
|
+
_getCollectionNames_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1124
|
+
_getCollectionInfos_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1125
|
+
_runCommand_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1126
|
+
_adminCommand_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1127
|
+
_aggregate_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('AggregationCursor'), (0, decorators_1.apiVersions)([1])];
|
|
1128
|
+
_getSiblingDB_decorators = [(0, decorators_1.returnType)('Database')];
|
|
1129
|
+
_getCollection_decorators = [(0, decorators_1.returnType)('Collection')];
|
|
1130
|
+
_dropDatabase_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1131
|
+
_createUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1132
|
+
_updateUser_decorators = [decorators_1.returnsPromise];
|
|
1133
|
+
_changeUserPassword_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1134
|
+
_logout_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1135
|
+
_dropUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1136
|
+
_dropAllUsers_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1137
|
+
_auth_decorators = [decorators_1.returnsPromise];
|
|
1138
|
+
_grantRolesToUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1139
|
+
_revokeRolesFromUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1140
|
+
_getUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1141
|
+
_getUsers_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1142
|
+
_createCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1143
|
+
_createEncryptedCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1144
|
+
_createView_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1145
|
+
_createRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1146
|
+
_updateRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1147
|
+
_dropRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1148
|
+
_dropAllRoles_decorators = [decorators_1.returnsPromise];
|
|
1149
|
+
_grantRolesToRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1150
|
+
_revokeRolesFromRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1151
|
+
_grantPrivilegesToRole_decorators = [decorators_1.returnsPromise];
|
|
1152
|
+
_revokePrivilegesFromRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1153
|
+
_getRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1154
|
+
_getRoles_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1155
|
+
_currentOp_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1156
|
+
_killOp_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1157
|
+
_shutdownServer_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1158
|
+
_fsyncLock_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1159
|
+
_fsyncUnlock_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1160
|
+
_version_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1161
|
+
_serverBits_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1162
|
+
_isMaster_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1163
|
+
_hello_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1]), (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])];
|
|
1164
|
+
_serverBuildInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1165
|
+
_serverStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1166
|
+
_stats_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1167
|
+
_hostInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1168
|
+
_serverCmdLineOpts_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1169
|
+
_rotateCertificates_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([])];
|
|
1170
|
+
_printCollectionStats_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1171
|
+
_getProfilingStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1172
|
+
_setProfilingLevel_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1173
|
+
_setLogLevel_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1174
|
+
_getLogComponents_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1175
|
+
_cloneDatabase_decorators = [decorators_1.deprecated];
|
|
1176
|
+
_cloneCollection_decorators = [decorators_1.deprecated];
|
|
1177
|
+
_copyDatabase_decorators = [decorators_1.deprecated];
|
|
1178
|
+
_commandHelp_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1179
|
+
_listCommands_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1180
|
+
_getLastErrorObj_decorators = [(0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '5.1.0']), decorators_1.deprecated, decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1181
|
+
_getLastError_decorators = [decorators_1.deprecated, decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1182
|
+
_printShardingStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([1])];
|
|
1183
|
+
_printSecondaryReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.ReplSet]), (0, decorators_1.apiVersions)([])];
|
|
1184
|
+
_getReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.ReplSet]), (0, decorators_1.apiVersions)([])];
|
|
1185
|
+
_printReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.topologies)([enums_1.Topologies.ReplSet])];
|
|
1186
|
+
_printSlaveReplicationInfo_decorators = [decorators_1.deprecated];
|
|
1187
|
+
_setSecondaryOk_decorators = [decorators_1.deprecated, decorators_1.returnsPromise];
|
|
1188
|
+
_watch_decorators = [(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([1]), decorators_1.returnsPromise];
|
|
1189
|
+
_sql_decorators = [(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.returnType)('AggregationCursor')];
|
|
1190
|
+
_checkMetadataConsistency_decorators = [(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), decorators_1.returnsPromise];
|
|
1191
|
+
__esDecorate(_classThis, null, _getMongo_decorators, { kind: "method", name: "getMongo", static: false, private: false, access: { has: obj => "getMongo" in obj, get: obj => obj.getMongo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1192
|
+
__esDecorate(_classThis, null, _getCollectionNames_decorators, { kind: "method", name: "getCollectionNames", static: false, private: false, access: { has: obj => "getCollectionNames" in obj, get: obj => obj.getCollectionNames }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1193
|
+
__esDecorate(_classThis, null, _getCollectionInfos_decorators, { kind: "method", name: "getCollectionInfos", static: false, private: false, access: { has: obj => "getCollectionInfos" in obj, get: obj => obj.getCollectionInfos }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1194
|
+
__esDecorate(_classThis, null, _runCommand_decorators, { kind: "method", name: "runCommand", static: false, private: false, access: { has: obj => "runCommand" in obj, get: obj => obj.runCommand }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1195
|
+
__esDecorate(_classThis, null, _adminCommand_decorators, { kind: "method", name: "adminCommand", static: false, private: false, access: { has: obj => "adminCommand" in obj, get: obj => obj.adminCommand }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1196
|
+
__esDecorate(_classThis, null, _aggregate_decorators, { kind: "method", name: "aggregate", static: false, private: false, access: { has: obj => "aggregate" in obj, get: obj => obj.aggregate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1197
|
+
__esDecorate(_classThis, null, _getSiblingDB_decorators, { kind: "method", name: "getSiblingDB", static: false, private: false, access: { has: obj => "getSiblingDB" in obj, get: obj => obj.getSiblingDB }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1198
|
+
__esDecorate(_classThis, null, _getCollection_decorators, { kind: "method", name: "getCollection", static: false, private: false, access: { has: obj => "getCollection" in obj, get: obj => obj.getCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1199
|
+
__esDecorate(_classThis, null, _dropDatabase_decorators, { kind: "method", name: "dropDatabase", static: false, private: false, access: { has: obj => "dropDatabase" in obj, get: obj => obj.dropDatabase }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1200
|
+
__esDecorate(_classThis, null, _createUser_decorators, { kind: "method", name: "createUser", static: false, private: false, access: { has: obj => "createUser" in obj, get: obj => obj.createUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1201
|
+
__esDecorate(_classThis, null, _updateUser_decorators, { kind: "method", name: "updateUser", static: false, private: false, access: { has: obj => "updateUser" in obj, get: obj => obj.updateUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1202
|
+
__esDecorate(_classThis, null, _changeUserPassword_decorators, { kind: "method", name: "changeUserPassword", static: false, private: false, access: { has: obj => "changeUserPassword" in obj, get: obj => obj.changeUserPassword }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1203
|
+
__esDecorate(_classThis, null, _logout_decorators, { kind: "method", name: "logout", static: false, private: false, access: { has: obj => "logout" in obj, get: obj => obj.logout }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1204
|
+
__esDecorate(_classThis, null, _dropUser_decorators, { kind: "method", name: "dropUser", static: false, private: false, access: { has: obj => "dropUser" in obj, get: obj => obj.dropUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1205
|
+
__esDecorate(_classThis, null, _dropAllUsers_decorators, { kind: "method", name: "dropAllUsers", static: false, private: false, access: { has: obj => "dropAllUsers" in obj, get: obj => obj.dropAllUsers }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1206
|
+
__esDecorate(_classThis, null, _auth_decorators, { kind: "method", name: "auth", static: false, private: false, access: { has: obj => "auth" in obj, get: obj => obj.auth }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1207
|
+
__esDecorate(_classThis, null, _grantRolesToUser_decorators, { kind: "method", name: "grantRolesToUser", static: false, private: false, access: { has: obj => "grantRolesToUser" in obj, get: obj => obj.grantRolesToUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1208
|
+
__esDecorate(_classThis, null, _revokeRolesFromUser_decorators, { kind: "method", name: "revokeRolesFromUser", static: false, private: false, access: { has: obj => "revokeRolesFromUser" in obj, get: obj => obj.revokeRolesFromUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1209
|
+
__esDecorate(_classThis, null, _getUser_decorators, { kind: "method", name: "getUser", static: false, private: false, access: { has: obj => "getUser" in obj, get: obj => obj.getUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1210
|
+
__esDecorate(_classThis, null, _getUsers_decorators, { kind: "method", name: "getUsers", static: false, private: false, access: { has: obj => "getUsers" in obj, get: obj => obj.getUsers }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1211
|
+
__esDecorate(_classThis, null, _createCollection_decorators, { kind: "method", name: "createCollection", static: false, private: false, access: { has: obj => "createCollection" in obj, get: obj => obj.createCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1212
|
+
__esDecorate(_classThis, null, _createEncryptedCollection_decorators, { kind: "method", name: "createEncryptedCollection", static: false, private: false, access: { has: obj => "createEncryptedCollection" in obj, get: obj => obj.createEncryptedCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1213
|
+
__esDecorate(_classThis, null, _createView_decorators, { kind: "method", name: "createView", static: false, private: false, access: { has: obj => "createView" in obj, get: obj => obj.createView }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1214
|
+
__esDecorate(_classThis, null, _createRole_decorators, { kind: "method", name: "createRole", static: false, private: false, access: { has: obj => "createRole" in obj, get: obj => obj.createRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1215
|
+
__esDecorate(_classThis, null, _updateRole_decorators, { kind: "method", name: "updateRole", static: false, private: false, access: { has: obj => "updateRole" in obj, get: obj => obj.updateRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1216
|
+
__esDecorate(_classThis, null, _dropRole_decorators, { kind: "method", name: "dropRole", static: false, private: false, access: { has: obj => "dropRole" in obj, get: obj => obj.dropRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1217
|
+
__esDecorate(_classThis, null, _dropAllRoles_decorators, { kind: "method", name: "dropAllRoles", static: false, private: false, access: { has: obj => "dropAllRoles" in obj, get: obj => obj.dropAllRoles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1218
|
+
__esDecorate(_classThis, null, _grantRolesToRole_decorators, { kind: "method", name: "grantRolesToRole", static: false, private: false, access: { has: obj => "grantRolesToRole" in obj, get: obj => obj.grantRolesToRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1219
|
+
__esDecorate(_classThis, null, _revokeRolesFromRole_decorators, { kind: "method", name: "revokeRolesFromRole", static: false, private: false, access: { has: obj => "revokeRolesFromRole" in obj, get: obj => obj.revokeRolesFromRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1220
|
+
__esDecorate(_classThis, null, _grantPrivilegesToRole_decorators, { kind: "method", name: "grantPrivilegesToRole", static: false, private: false, access: { has: obj => "grantPrivilegesToRole" in obj, get: obj => obj.grantPrivilegesToRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1221
|
+
__esDecorate(_classThis, null, _revokePrivilegesFromRole_decorators, { kind: "method", name: "revokePrivilegesFromRole", static: false, private: false, access: { has: obj => "revokePrivilegesFromRole" in obj, get: obj => obj.revokePrivilegesFromRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1222
|
+
__esDecorate(_classThis, null, _getRole_decorators, { kind: "method", name: "getRole", static: false, private: false, access: { has: obj => "getRole" in obj, get: obj => obj.getRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1223
|
+
__esDecorate(_classThis, null, _getRoles_decorators, { kind: "method", name: "getRoles", static: false, private: false, access: { has: obj => "getRoles" in obj, get: obj => obj.getRoles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1224
|
+
__esDecorate(_classThis, null, _currentOp_decorators, { kind: "method", name: "currentOp", static: false, private: false, access: { has: obj => "currentOp" in obj, get: obj => obj.currentOp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1225
|
+
__esDecorate(_classThis, null, _killOp_decorators, { kind: "method", name: "killOp", static: false, private: false, access: { has: obj => "killOp" in obj, get: obj => obj.killOp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1226
|
+
__esDecorate(_classThis, null, _shutdownServer_decorators, { kind: "method", name: "shutdownServer", static: false, private: false, access: { has: obj => "shutdownServer" in obj, get: obj => obj.shutdownServer }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1227
|
+
__esDecorate(_classThis, null, _fsyncLock_decorators, { kind: "method", name: "fsyncLock", static: false, private: false, access: { has: obj => "fsyncLock" in obj, get: obj => obj.fsyncLock }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1228
|
+
__esDecorate(_classThis, null, _fsyncUnlock_decorators, { kind: "method", name: "fsyncUnlock", static: false, private: false, access: { has: obj => "fsyncUnlock" in obj, get: obj => obj.fsyncUnlock }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1229
|
+
__esDecorate(_classThis, null, _version_decorators, { kind: "method", name: "version", static: false, private: false, access: { has: obj => "version" in obj, get: obj => obj.version }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1230
|
+
__esDecorate(_classThis, null, _serverBits_decorators, { kind: "method", name: "serverBits", static: false, private: false, access: { has: obj => "serverBits" in obj, get: obj => obj.serverBits }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1231
|
+
__esDecorate(_classThis, null, _isMaster_decorators, { kind: "method", name: "isMaster", static: false, private: false, access: { has: obj => "isMaster" in obj, get: obj => obj.isMaster }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1232
|
+
__esDecorate(_classThis, null, _hello_decorators, { kind: "method", name: "hello", static: false, private: false, access: { has: obj => "hello" in obj, get: obj => obj.hello }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1233
|
+
__esDecorate(_classThis, null, _serverBuildInfo_decorators, { kind: "method", name: "serverBuildInfo", static: false, private: false, access: { has: obj => "serverBuildInfo" in obj, get: obj => obj.serverBuildInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1234
|
+
__esDecorate(_classThis, null, _serverStatus_decorators, { kind: "method", name: "serverStatus", static: false, private: false, access: { has: obj => "serverStatus" in obj, get: obj => obj.serverStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1235
|
+
__esDecorate(_classThis, null, _stats_decorators, { kind: "method", name: "stats", static: false, private: false, access: { has: obj => "stats" in obj, get: obj => obj.stats }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1236
|
+
__esDecorate(_classThis, null, _hostInfo_decorators, { kind: "method", name: "hostInfo", static: false, private: false, access: { has: obj => "hostInfo" in obj, get: obj => obj.hostInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1237
|
+
__esDecorate(_classThis, null, _serverCmdLineOpts_decorators, { kind: "method", name: "serverCmdLineOpts", static: false, private: false, access: { has: obj => "serverCmdLineOpts" in obj, get: obj => obj.serverCmdLineOpts }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1238
|
+
__esDecorate(_classThis, null, _rotateCertificates_decorators, { kind: "method", name: "rotateCertificates", static: false, private: false, access: { has: obj => "rotateCertificates" in obj, get: obj => obj.rotateCertificates }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1239
|
+
__esDecorate(_classThis, null, _printCollectionStats_decorators, { kind: "method", name: "printCollectionStats", static: false, private: false, access: { has: obj => "printCollectionStats" in obj, get: obj => obj.printCollectionStats }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1240
|
+
__esDecorate(_classThis, null, _getProfilingStatus_decorators, { kind: "method", name: "getProfilingStatus", static: false, private: false, access: { has: obj => "getProfilingStatus" in obj, get: obj => obj.getProfilingStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1241
|
+
__esDecorate(_classThis, null, _setProfilingLevel_decorators, { kind: "method", name: "setProfilingLevel", static: false, private: false, access: { has: obj => "setProfilingLevel" in obj, get: obj => obj.setProfilingLevel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1242
|
+
__esDecorate(_classThis, null, _setLogLevel_decorators, { kind: "method", name: "setLogLevel", static: false, private: false, access: { has: obj => "setLogLevel" in obj, get: obj => obj.setLogLevel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1243
|
+
__esDecorate(_classThis, null, _getLogComponents_decorators, { kind: "method", name: "getLogComponents", static: false, private: false, access: { has: obj => "getLogComponents" in obj, get: obj => obj.getLogComponents }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1244
|
+
__esDecorate(_classThis, null, _cloneDatabase_decorators, { kind: "method", name: "cloneDatabase", static: false, private: false, access: { has: obj => "cloneDatabase" in obj, get: obj => obj.cloneDatabase }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1245
|
+
__esDecorate(_classThis, null, _cloneCollection_decorators, { kind: "method", name: "cloneCollection", static: false, private: false, access: { has: obj => "cloneCollection" in obj, get: obj => obj.cloneCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1246
|
+
__esDecorate(_classThis, null, _copyDatabase_decorators, { kind: "method", name: "copyDatabase", static: false, private: false, access: { has: obj => "copyDatabase" in obj, get: obj => obj.copyDatabase }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1247
|
+
__esDecorate(_classThis, null, _commandHelp_decorators, { kind: "method", name: "commandHelp", static: false, private: false, access: { has: obj => "commandHelp" in obj, get: obj => obj.commandHelp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1248
|
+
__esDecorate(_classThis, null, _listCommands_decorators, { kind: "method", name: "listCommands", static: false, private: false, access: { has: obj => "listCommands" in obj, get: obj => obj.listCommands }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1249
|
+
__esDecorate(_classThis, null, _getLastErrorObj_decorators, { kind: "method", name: "getLastErrorObj", static: false, private: false, access: { has: obj => "getLastErrorObj" in obj, get: obj => obj.getLastErrorObj }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1250
|
+
__esDecorate(_classThis, null, _getLastError_decorators, { kind: "method", name: "getLastError", static: false, private: false, access: { has: obj => "getLastError" in obj, get: obj => obj.getLastError }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1251
|
+
__esDecorate(_classThis, null, _printShardingStatus_decorators, { kind: "method", name: "printShardingStatus", static: false, private: false, access: { has: obj => "printShardingStatus" in obj, get: obj => obj.printShardingStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1252
|
+
__esDecorate(_classThis, null, _printSecondaryReplicationInfo_decorators, { kind: "method", name: "printSecondaryReplicationInfo", static: false, private: false, access: { has: obj => "printSecondaryReplicationInfo" in obj, get: obj => obj.printSecondaryReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1253
|
+
__esDecorate(_classThis, null, _getReplicationInfo_decorators, { kind: "method", name: "getReplicationInfo", static: false, private: false, access: { has: obj => "getReplicationInfo" in obj, get: obj => obj.getReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1254
|
+
__esDecorate(_classThis, null, _printReplicationInfo_decorators, { kind: "method", name: "printReplicationInfo", static: false, private: false, access: { has: obj => "printReplicationInfo" in obj, get: obj => obj.printReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1255
|
+
__esDecorate(_classThis, null, _printSlaveReplicationInfo_decorators, { kind: "method", name: "printSlaveReplicationInfo", static: false, private: false, access: { has: obj => "printSlaveReplicationInfo" in obj, get: obj => obj.printSlaveReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1256
|
+
__esDecorate(_classThis, null, _setSecondaryOk_decorators, { kind: "method", name: "setSecondaryOk", static: false, private: false, access: { has: obj => "setSecondaryOk" in obj, get: obj => obj.setSecondaryOk }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1257
|
+
__esDecorate(_classThis, null, _watch_decorators, { kind: "method", name: "watch", static: false, private: false, access: { has: obj => "watch" in obj, get: obj => obj.watch }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1258
|
+
__esDecorate(_classThis, null, _sql_decorators, { kind: "method", name: "sql", static: false, private: false, access: { has: obj => "sql" in obj, get: obj => obj.sql }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1259
|
+
__esDecorate(_classThis, null, _checkMetadataConsistency_decorators, { kind: "method", name: "checkMetadataConsistency", static: false, private: false, access: { has: obj => "checkMetadataConsistency" in obj, get: obj => obj.checkMetadataConsistency }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1260
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1261
|
+
Database = _classThis = _classDescriptor.value;
|
|
1262
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1263
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1264
|
+
})();
|
|
1265
|
+
return Database = _classThis;
|
|
1266
|
+
})();
|
|
1293
1267
|
exports.default = Database;
|
|
1294
1268
|
//# sourceMappingURL=database.js.map
|