id = "mongoimport" name = "mongoimport" description = "Import data from a JSON, CSV, or TSV file into a MongoDB instance." homepage = "https://www.mongodb.com/docs/database-tools/mongoimport/" executables = ["mongoimport"] [commands] format = 1 label = "Import data" description = "Import a JSON, CSV or TSV file into a collection. Credentials, TLS and Kerberos options are left out; put credentials in a connection URI or config file instead." quality = "ai-draft" base = "fig:mongoimport" parser = { end_of_options = "--", interleave = "permute", long_equals = true, short_attached = true, short_bundles = false } [[commands.source]] id = "fig" kind = "completion" url = "https://github.com/withfig/autocomplete/blob/master/src/mongoimport.ts" license = "MIT" [[commands.field]] id = "uri" label = "Connection URI" type = "string" option = ["--uri"] suggestions = [{ value = "mongodb://localhost:27017", label = "Local" }] sources = ["fig"] [[commands.field]] id = "host" label = "Host" type = "string" option = ["--host"] suggestions = [{ value = "localhost:27017", label = "localhost:27017" }] sources = ["fig"] [[commands.field]] id = "db" label = "Database" type = "string" option = ["--db", "-d"] sources = ["fig"] [[commands.field]] id = "collection" label = "Collection" type = "string" option = ["--collection", "-c"] sources = ["fig"] [[commands.field]] id = "file" label = "Input file" type = "path" option = ["--file"] path = { kind = "file", role = "input" } sources = ["fig"] [[commands.field]] id = "type" label = "File type" type = "string" option = ["--type"] suggestions = [{ value = "json", label = "JSON" }, { value = "csv", label = "CSV" }, { value = "tsv", label = "TSV" }] sources = ["fig"] [[commands.field]] id = "headerline" label = "First line is header" type = "boolean" option = ["--headerline"] sources = ["fig"] [[commands.field]] id = "fields" label = "Field names" description = "Comma-separated, for CSV/TSV files without a header line." type = "string" option = ["--fields", "-f"] sources = ["fig"] [[commands.field]] id = "mode" label = "Import mode" description = "How to handle existing documents that match." type = "string" option = ["--mode"] suggestions = [{ value = "insert", label = "Insert" }, { value = "upsert", label = "Upsert" }, { value = "merge", label = "Merge" }, { value = "delete", label = "Delete" }] sources = ["fig"] [[commands.field]] id = "upsert_fields" label = "Upsert fields" type = "string" option = ["--upsertFields"] sources = ["fig"] [[commands.field]] id = "drop" label = "Drop collection first" description = "Drops the target collection before importing." type = "boolean" option = ["--drop"] effect = "delete" sources = ["fig"] [[commands.field]] id = "stop_on_error" label = "Stop on first error" type = "boolean" option = ["--stopOnError"] sources = ["fig"] [[commands.task]] id = "import-csv" label = "Import a CSV with header" fields = ["uri", "db", "collection", "file", "type", "headerline"] set = { type = ["csv"], headerline = [true] } required = ["db", "collection", "file"] [[commands.task]] id = "import-json" label = "Import a JSON file" fields = ["uri", "db", "collection", "file", "mode", "drop"] required = ["db", "collection", "file"] [[commands.group]] id = "basic" label = "Basic" fields = ["uri", "host", "db", "collection", "file", "type"] [[commands.group]] id = "advanced" label = "Advanced" fields = ["headerline", "fields", "mode", "upsert_fields", "drop", "stop_on_error"]