-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathmongoimport.ts
389 lines (386 loc) · 11.1 KB
/
mongoimport.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
// https://www.mongodb.com/docs/database-tools/mongoimport
import { filepaths } from "@fig/autocomplete-generators";
const completionSpec: Fig.Spec = {
name: "mongoimport",
description:
"Import data from a JSON, CSV, or TSV file into a MongoDB instance",
options: [
{
name: "--help",
description: "Returns information on the options and use of mongoimport",
},
{
name: ["--verbose", "-v"],
description:
"Increases the amount of internal reporting returned on standard output or in log files",
},
{
name: "--quiet",
description:
"Runs mongoimport in a quiet mode that attempts to limit the amount of output",
},
{
name: "--version",
description: "Returns the mongoimport release number",
},
{
name: "--config",
description:
"Specifies the full path to a YAML configuration file containing sensitive values for the following options to mongoimport",
args: {
name: "filename",
generators: filepaths({ extensions: ["yaml", "yml"] }),
},
},
{
name: "--uri",
description:
"Specifies the resolvable URI connection string of the MongoDB deployment",
priority: 100,
args: {
name: "connectionString",
description: "MongoDB connection string",
suggestions: [
{
name: "mongodb://localhost:27017",
description: "Default Connection String",
},
{
name: "mongodb+srv://username:[email protected]/database",
description: "Atlas Connection String Example",
priority: 35,
},
],
},
},
{
name: ["--host", "-h"],
description:
"Specifies the resolvable hostname of the MongoDB deployment",
args: {
name: "hostname:port",
suggestions: [
{
name: "localhost:27017",
description: "Default host",
},
],
},
},
{
name: "--port",
description:
"Specifies the TCP port on which the MongoDB instance listens for client connections",
args: {
name: "port",
suggestions: [
{
name: "27017",
description: "Default port",
},
],
},
},
{
name: "--ssl",
description:
"Enables connection to a mongod or mongos that has TLS/SSL support enabled",
},
{
name: "--sslCAFile",
description:
"Specifies the .pem file that contains the root certificate chain from the Certificate Authority",
args: {
name: "filename",
generators: filepaths({ extensions: ["pem"] }),
},
},
{
name: "--sslPEMKeyFile",
description:
"Specifies the .pem file that contains both the TLS/SSL certificate and key",
args: {
name: "filename",
generators: filepaths({ extensions: ["pem"] }),
},
},
{
name: "--sslPEMKeyPassword",
description:
"Specifies the password to de-crypt the certificate-key file (i.e. --sslPEMKeyFile)",
args: {
name: "value",
description: "Password",
isDangerous: true,
},
},
{
name: "--sslCRLFile",
description:
"Specifies the .pem file that contains the Certificate Revocation List",
args: {
name: "filename",
generators: filepaths({ extensions: ["pem"] }),
},
},
{
name: "--sslAllowInvalidCertificates",
description:
"Bypasses the validation checks for server certificates and allows the use of invalid certificates",
},
{
name: "--sslAllowInvalidHostnames",
description:
"Disables the validation of the hostnames in TLS/SSL certificates",
},
{
name: ["--username", "-u"],
description:
"Specifies a username with which to authenticate to a MongoDB database that uses authentication",
args: { name: "username" },
},
{
name: ["--password", "-p"],
description:
"Specifies a password with which to authenticate to a MongoDB database that uses authentication",
dependsOn: ["--username"],
args: {
name: "password",
isDangerous: true,
},
},
{
name: "--awsSessionToken",
description:
"Specifies the session token for MONGODB-AWS authentication mechanism",
args: { name: "AWS Session Token" },
},
{
name: "--authenticationDatabase",
description:
"Specifies the authentication database where the specified --username has been created",
args: {
name: "dbname",
description: "Database name",
},
},
{
name: "--authenticationMechanism",
description:
"Specifies the authentication mechanism the mongoimport instance uses to authenticate to the mongod or mongos",
args: {
name: "name",
suggestions: [
{
name: "SCRAM-SHA-1",
description: "Default",
},
{ name: "SCRAM-SHA-256" },
{ name: "MONGODB-X509" },
{ name: "MONGODB-AWS" },
{ name: "GSSAPI" },
{ name: "PLAIN" },
],
},
},
{
name: "--gssapiServiceName",
description:
"Specify the name of the service using GSSAPI/Kerberos. This option is available only in MongoDB Enterprise",
args: {
name: "serviceName",
},
},
{
name: "--gssapiHostName",
description:
"Specify the hostname of the service using GSSAPI/Kerberos. This option is available only in MongoDB Enterprise",
args: { name: "hostname" },
},
{
name: ["--db", "-d"],
description:
"Specifies the name of the database on which to run the mongoimport",
args: { name: "database" },
},
{
name: ["--collection", "-c"],
description: "Specifies the name of the collection to import",
priority: 90,
args: { name: "collection" },
},
{
name: ["--fields", "-f"],
description:
"Specify a comma separated list of field names when importing CSV or TSV files that do not have field names in the first (i.e. header) line of the file",
exclusiveOn: ["--fieldFile"],
args: {
name: "field1,field2,...",
description: "Comma separated list of fields",
},
},
{
name: "--fieldFile",
description:
"Specify a file containing a comma separated list of field names when importing CSV or TSV files that do not have field names in the first (i.e. header) line of the file",
exclusiveOn: ["--fields", "-f"],
args: {
name: "filename",
generators: filepaths({ extensions: ["csv", "tsv"] }),
},
},
{
name: "--ignoreBlanks",
description: "Ignores empty fields in CSV and TSV exports",
},
{
name: "--type",
description: "Specifies the file type to import",
args: {
name: "type",
suggestions: [
{
name: "json",
description: "JSON",
},
{
name: "csv",
description: "Comma-separated values",
},
{
name: "tsv",
description: "Tab-separated values",
},
],
},
},
{
name: "--file",
description:
"Specifies the location and name of a file containing the data to import",
priority: 80,
args: {
name: "filename",
generators: filepaths({ extensions: ["json", "csv", "tsv"] }),
},
},
{
name: "--drop",
description:
"Modifies the import process so that the target instance drops the collection before importing the data from the input",
},
{
name: "--headerline",
description: "Treats the first line of the input file as a header line",
},
{
name: "--useArrayIndexFields",
description:
"Interpret natural numbers in fields as array indexes when importing CSV or TSV files",
},
{
name: "--mode",
description:
"Specifies how the import process should handle existing documents in the database that match documents in the import file",
priority: 80,
args: {
name: "mode",
suggestions: [
{
name: "insert",
description: "Insert the documents in the import file",
},
{
name: "upsert",
description:
"Replace existing documents in the database with matching documents from the import file",
},
{
name: "merge",
description:
"Merge existing documents that match a document in the import file with the new document",
},
{
name: "delete",
description:
"Delete existing documents in the database that match a document in the import file",
},
],
},
},
{
name: "--upsertFields",
description:
"Specifies a list of fields for the query portion of the import process",
args: {
name: "field1,field2,...",
description: "Comma separated list of fields",
},
},
{
name: "--stopOnError",
description:
"Forces mongoimport to halt the insert operation at the first error rather than continuing the operation despite errors",
},
{
name: "jsonArray",
description:
"Accepts the import of data expressed with multiple MongoDB documents within a single JSON array",
},
{
name: "--legacy",
description:
"Indicates that the import data is in Extended JSON v1 format",
},
{
name: "--maintainInsertionOrder",
description:
"Maintains the order of documents in the import file when inserting documents into the database",
},
{
name: "--numInsertionWorkers",
description:
"Specifies the number of insertion workers to run concurrently",
args: {
name: "number",
description: "Number of workers",
default: "1",
},
},
{
name: "--writeConcern",
description:
"Specifies the write concern for each write operation that mongoimport performs",
args: {
name: "document",
default: "{w:'majority'}",
},
},
{
name: "--bypassDocumentValidation",
description:
"Enables mongoimport to bypass document validation during the operation",
},
{
name: "--columnsHaveTypes",
description:
"Instructs mongoimport that the field list specified in --fields, --fieldFile, or --headerline specifies the types of each field",
},
{
name: "--parseGrace",
description:
"Specifies how mongoimport handles type coercion failures when importing CSV or TSV files with --columnsHaveTypes",
args: {
name: "grace",
default: "stop",
suggestions: [
{ name: "autoCast" },
{ name: "skipField" },
{ name: "skipRow" },
{ name: "stop" },
],
},
},
],
};
export default completionSpec;