mongoback.euber.dev Open in urlscan Pro
76.76.21.22  Public Scan

URL: https://mongoback.euber.dev/
Submission: On July 25 via automatic, source certstream-suspicious — Scanned from CA

Form analysis 0 forms found in the DOM

Text Content

Search
 * Preparing search index...
 * The search index is not available

mongoback - v3.0.2
Options
All
 * Public
 * Public/Protected
 * All

Inherited
Menu


MONGOBACK - V3.0.2


MONGOBACK

The most powerful npm module to export your MongoDB.

This is a wrapper of the mongoexport tool and comes because of the annoy of
typing everything in the command line, repeating the task for every collection
to export.

This module allows to call it in a more comfortable way and to export multiple
collections at a time. It allows you to select collections in a powerful way and
saves the exported files in an organized and customizable directory.


INSTALL

Before installing mongoback, you need the mongoexport installed and its path
added to the envinronments variables. This should automatically happen when
installing MongoDB.

To install mongoback as a local module:

$ npm install mongoback



USAGE (LOCAL MODULE)


A FIRST EXAMPLE

This tiny code (main.js):

const { mongoExport } = require('mongoback');
const options = { all: true };

await mongoExport(options);


Will result in this:



And the created exported directory will be like this:

exported
 ├─> 12345
 │   ├── first.json
 │   └── second.json
 └─> animals
     ├── cats.json
     ├── dogs.json
     ├── horses.json
     ├── lions.csv
     ├── pinguins.json
     └── tigers.csv



USAGE (GLOBAL MODULE)

Executing the command:

$ mongoback export



Execute the help command for more informaition:

$ mongoback --help


FEATURES

The module allows you to:

 * Specify all the mongodb connection uri and options
 * Specify in a powerful way the collections to export
 * By using RegExp and functions, export collections you do not know they exist
 * Specify in a powerful way all the mongoexport options for each collection
 * Specify in a powerful way in which path end with which file name will every
   collection be saved
 * Specify the output directory and its structure
 * Specify if and how show the function logs
 * Specify if an error will be thrown in case not all collections can be
   fetched/exported


HOW IT WORKS

The module:

 * Checks if mongoexport is installed
 * Parses the options and, connecting to the mongodb, gets all the name of the
   collections that you want to export
 * By calling mongoexport, exports the collections and saves them in a directory
   structure customizable by the options
 * Returns an object containing information about what has been exported

To learn well to use the module, it is suggested to see the examples below
before reading the API.


EXAMPLES


SPECIFY THE MONGODB CONNECTION

THIS WILL EXPORT ALL THE COLLECTIONS IN MONGODB://MYHOST:27017.

const { mongoExport } = require('mongoback');
const options = { 
    uri: 'mongodb://user:secret@myhost:27017',
    all: true 
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS IN MONGODB://MYHOST:8080

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    all: true 
};

await mongoExport(options);


THIS WILL ADD USERNAME AND PASSWORD:

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    username: 'me',
    password: 'secret',
    auhenticationDatabase: 'administrator',
    all: true 
};

await mongoExport(options);


THIS WILL ADD SRV (MONGODB+SRV//MYHOST:8080):

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    srv: true,
    all: true 
};

await mongoExport(options);


THIS WILL USE A REPLICA SET CONNECTION:

const { mongoExport } = require('mongoback');
const options = { 
    host: [
        { host: 'localhost', port: 27017 },
        { host: 'myhost': port: 23023 }
    ],
    replicaSetName: 'replicas',
    all: true 
};

await mongoExport(options);



SPECIFY WHAT IS TO BE EXPORTED

THIS WILL EXPORT ALL THE COLLECTIONS IN MONGODB://LOCALHOST:27017:

const { mongoExport } = require('mongoback');
const options = { all: true };

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS OF DATABASE ANIMALS:

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: 'animals'
};

await mongoExport(options);


THIS WILL EXPORT ALL THE DATABASES BEGINNING WITH TEST:

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: /^test/
};

await mongoExport(options);


THIS WILL EXPORT THE ANIMALS DATABASE AND THE ONES BEGINNING WITH TEST:

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: ['animals', /^test/]
};

await mongoExport(options);


THIS WILL EXPORT ALL THE DATABASES BEGINNING WITH TEST. EVERY EXPORTED
COLLECTION WILL HAVE ALSO THE --JSONARRAY MONGOEXPORT OPTION.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: { 
        match: /^test/, 
        jsonArray: true 
    }
};

await mongoExport(options);


THIS WILL EXPORT THE ANIMALS DATABASE AND THE ONES BEGINNING WITH TEST. ALL
COLLECTIONS EXPORTED BY THE ANIMALS DATABASE WILL HAVE ALSO THE --JSONARRAY
MONGOEXPORT OPTION.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: [
        /^test/,
        { match: 'animals', jsonArray: true }
    ]
};

await mongoExport(options);


THIS WILL EXPORT THE DATABASE ANIMALS AND ALL THE DATABASES WHOSE LENGTH IS 4

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: [
        'animals',
        (db) => (db.length === 4)
    ]
};

await mongoExport(options);


THIS WILL EXPORT ALL THE DATABASES WHOSE LENGTH IS 4, ADDING THE --PRETTY AND
--LIMIT=5 MONGOEXPORT OPTIONS TO EACH OF THEM.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: function(db) {
        if (db.length === 4) {
            return {
                pretty: true,
                limit: 5
            };
        }
    }
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS. THE ONES OF THE DATABASE ANIMALS WILL BE
THE ONLY ONE TO BE OF TYPE JSON. THIS IS BECAUSE THE EXPORTING OPTIONS SPECIFIED
INSIDE DATABASES OVERWRITE THE GENERAL ONES.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    type: 'csv',
    fields: ['timestamp', 'name'],
    databases: {
        match: 'animals',
        type: 'json'
    }
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS (IN ANY DATABASE) WHOSE NAME IS KEBAB

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    collections: 'kebab'
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS (IN ANY DATABASE) WHOSE NAME IS KEBAB OR
THAT BEGIN WITH TEST

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    collections: ['kebab', /^test/]
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS WHOSE DATABASE BEGINS WITH A AND WHOSE NAME
IS OF LENGTH GREATER THAN 5. ALL THESE COLLECTIONS WILL HAVE ALSO THE --PRETTY
MONGOEXPORT OPTION.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    collections: function(db, collection) {
        if (db[0] === 'a' && collection.length > 5) {
            return {
                pretty: true
            };
        }
    }
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS IN DATABASE ANIMALS AND ALL THE COLLECTIONS
BEGINNING WITH A OR B. ALL THE COLLECTIONS HAVE THE --PRETTY OPTION. THE
COLLECTIONS OF DATABASE ANIMALS WILL HAVE THE --JSONFORMAT=CANONICAL OPTION. THE
COLLECTIONS BEGINNING WITH A WILL HAVE THE --JSONFORMAT=RELAXED OPTION, EVEN IF
THEY ARE IN THE DATABASE ANIMALS. THIS IS BECAUSE THE COLLECTIONS EXPORTING
OPTIONS OVERWRITE THE DATABASE ONES.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    pretty: true,
    databases: {
        match: 'animals',
        jsonFormat: 'canonical'
    },
    collections: [
        {
            match: /^a/,
            jsonFormat: 'relaxed'
        },
        /^b/
    ]
};

await mongoExport(options);


THIS WILL EXPORT THE COLLECTIONS TIGER AND THE ONES BEGINNING WITH C OR C OF THE
DATABASE ANIMALS, THE COLLECTIONS STUDENTS AND TEACHERS OF THE DATABASE PEOPLE
AND THE COLLECTION VALDAGNO OF THE DATABASE CITIES.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    collections: {
        animals: ['tiger', /^c/i],
        people: ['sutdents', 'teachers'],
        cities: 'valdagno'
    }
};

await mongoExport(options);


THIS WILL EXPORT THE COLLECTIONS WOMBATS AND THE ONES WHOSE NAME LENGTH IS LOWER
THAN 5 OF THE DATABASE ANIMALS.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    collections: {
        animals: [
            'wombats',
            (_db, collection) => collection.length < 5
        ]
    }
};

await mongoExport(options);


THIS WILL EXPORT THE COLLECTIONS TIGERS, PINGUINS AND BEARS OF THE DATABASE
ANIMALS AND THE COLLECTION STUDENTS OF THE DATABASE PEOPLE. ALMOST ALL
COLLECTIONS WILL HAVE THE ``--PRETTYOPTION. ALL THE COLLECTIONS OFANIMALSWILL
NOT HAVE THE--JSONARRAYOPTION. ALL THE COLLECTIONS OFANIMALSWILL HAVE
THE--PRETTYOPTION, EXCEPT FORBEARS`. THIS IS BECAUSE THE EXPORTING OPTIONS
SPECIFIED IN A COLLECTION OVERWRITE THE ONES SPECIFIED IN A DATABASE THAT
OVERWRITE THE ONES SPECIFIED IN THE OPTIONS.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    pretty: true,
    collections: {
        animals: {
            collections: [
                'tigers',
                'pinguins',
                {
                    match: 'bears',
                    pretty: true
                }
            ],
            pretty: false,
            jsonArray: true
        }
    }
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS OF THE DATABASE ANIMALS. ALL THE
COLLECTIONS WILL HAVE THE --JSONARRAY OPTIONS, EXCEPT FOR THE TIGERS AND
PINGUINS THAT WILL HAVE THE --PRETTY OPTION INSTEAD.

This is because order of which the collections are exported is:

 * collections bound to a database
 * collections bound to no database
 * databases
 * all

If, as in this case, the collections tigers and pinguins are matched by the
databases option but are already matched by the collections one, they are
ignored and the exporting options in databases will not worth for them.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    databases: {
        match: 'animals',
        jsonArray: true
    },
    collections: {
        animals: {
            collections:  ['tigers', 'pinguins'],
            pretty: true
        }
    }
};

await mongoExport(options);


THIS WILL EXPORT THE COLLECTIONS TIGERS AND LIONS OF THE DATABASE ANIMALS, THE
COLLECTION STUDENTS AND ALL THE COLLECTIONS BEGINNING WITH P OR S OF THE
DATABASE PEOPLE AND ALL THE COLLECTIONS WHOSE DATABASE NAME LENGTH IS GREATER
THAN 6 AND WHOSE NAME BEGINS WITH T. ALL THE COLLECTIONS BEGINNING WITH P OR S
OF THE DATABASE PEOPLE WILL BE EXPORTED AS CSV AND THE STUDENTS ONE WILL ALSO
HAVE THE --NOHEADERLINE OPTION. ALL THE COLLECTIONS WHOSE DATABASE NAME LENGTH
IS GREATER THAN 5 AND WHOSE COLLECTION NAME BEGINS WITH T WILL HAVE THE
--SKIP=20 OPTION, EXCEPT FOR TIGERS THAT IS ALREADY EXPORTED WITHOUT THAT
OPTION.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    pretty: true,
    collections: [
        {
            animals: ['tigers', 'lions'], 
            people: {
                collections: [
                    {
                        match: 'students',
                        noHeaderLine: true
                    },
                    /^p/, 
                    /^s/
                ],
                type: 'csv',
                fields: 'timestamp'
            }
        },
        (db, collection) => {
            if (db.length > 6 && collection[0] === 't') {
                return { skip: 20 };
            }
        }
    ]
};

await mongoExport(options);


THIS SEEMS EXACTLY THE SAME EXAMPLE OF THE ONE DIRECTLY ABOVE, BUT ITS RESULT IS
ACTUALLY DIFFERENT. IN THIS EXAMPLE, THE COLLECTION STUDENTS OF THE DATABASE
PEOPLE WILL NOT HAVE THE --NOHEADERLINE OPTION. THIS IS BECAUSE THE ORDER OF THE
ELEMENTS OF AN ARRAY MATTERS FOR THE MONGOEXPORT FUNCTION. I THIS CASE, THE
OBJECT CONTAINING NOHEADERLINE AND BOUND TO THE COLLECTION STUDENTS OF THE
DATABASE PEOPLE COMES AFTER THE REGEXP /^S/. MATCHING THAT REGEXP, STUDENTS WILL
BE ALREADY EXPORTED WHEN THE OBJECT CONTAINING NOHEADERLINE WILL BE CONSIDERED,
HENCE THE OBJECT WILL BE IGNORED.

const { mongoExport } = require('mongoback');
const options = { 
    host: 'myhost',
    port: 8080,
    pretty: true,
    collections: [
        {
            animals: ['tigers', 'lions'], 
            people: {
                collections: [
                    /^p/, 
                    /^s/,
                    {
                        match: 'students',
                        noHeaderLine: true
                    }
                ],
                type: 'csv',
                fields: 'timestamp'
            }
        },
        (db, collection) => {
            if (db.length > 5 && collection[0] === 't') {
                return { skip: 20 };
            }
        }
    ]
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS, INCLUDING EVEN THE SYSTEM COLLECTIONS.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    systemCollections: true
};

await mongoExport(options);



SPECIFY ERRORS AND WARNING OPTIONS

THIS WILL EXPORT ALL THE COLLECTIONS. AN ERROR WILL BE THROWN WETHER IT WAS NOT
POSSIBLE (PROBABLY FOR LACK OF PERMISSIONS) TO LIST THE DATABASES OR THE
COLLECTIONS OF A DATABASE. USUALLY, WHEN THIS HAPPENS, THOSE COLLECTIONS ARE
IGNORED AND ALL WHAT COULD BE FETCHED ARE EXPORTED.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    throwIfLackOfPermissions: true
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS. AN ERROR WILL BE THROWN WETHER THERE WAS
AN ERROR IN ONE OF THE MONGOEXPORT EXECUTIONS. USUALLY, WHEN THIS HAPPENS, THE
ERROR IS IGNORED AND THE RESULT CODE WILL BE PARTIAL (1) INSTEAD OF TOTAL (0).

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    throwIfOneFails: true
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS. A WARNING MESSAGE IS LOGGED WETHER THERE
WAS A LACK OF PERMISSIONS ERROR OR A MONGOEXPORT ERROR.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    warnIfLackOfPermissions: true,
    warnIfOneFails: true
};

await mongoExport(options);



SPECIFYING WERE WILL THE FILES BE SAVED

THIS WILL EXPORT ALL THE COLLECTIONS. THE RESULT FILES WILL BE SAVED IN THE
DIRECTORY ./BACKUP AND NOT IN THE PATH ./EXPORTED AS PER DEFAULT. PER DEFAULT, A
FOLDER WILL BE CREATED FOR EACH DATABASE AND FOR EVERY EXPORTED COLLECTION THE
FILE NAME WILL BE THE COLLECTION NAME AND LOCATION IN THE FOLDER BOUND TO ITS
DATABASE NAME.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    outDir: './backup'
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS. INSTEAD OF CREATING A FOLDER FOR EACH
DATABASE, THE COLLECTIONS FILES WILL BE SAVED DIRECTLY IN THE BACKUP FOLDER AND
THE FILE NAME WILL BE DATABASE_COLLECTION.EXTENSION.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    outType: 'flat',
    outDir: './backup'
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS OF ANIMALS AND PEOPLE. THE FILES OF THE
COLLECTIONS STUDENTS AND TEACHER OF THE DATABASE PEOPLE WILL BE PREPENDED BY THE
DATABASE NAME. THE FILE OF THE TIGERS COLLECTION OF THE DATABASE ANIMALS WILL BE
TIGRI.JSON. THE FILE OF THE PINGUINS COLLECTION OF THE DATABASE ANIMALS WILL BE
PINGUINS.ANIMALS.JSON.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    databases: [`animals`, `people`],
    collections: {
        animals: [
            {
                match: 'tigers',
                fileName: 'tigri'
            },
            {
                match: 'pinguins',
                fileName: (db, collection, type) => `${collection}.${db}.${type}`
            }
        ],
        people: {
            collections: ['students', 'teachers'],
            prependDbName: true
        }
    },
    outDir: './backup'
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS OF ANIMALS AND PEOPLE. THE FILES OF THE
COLLECTIONS STUDENTS AND TEACHER OF DATABASE PEOPLE WILL BE IN A PATH
./DATABASE/COLLECTION/COLLECTION.JSON, RELATIVE TO THE OUTDIR FOLDER. THE FILE
OF THE TIGERS COLLECTION OF THE DATABASE ANIMALS WILL BE SAVED IN THE DESKTOP.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    databases: [`animals`, `people`],
    collections: {
        animals: {
            collections: 'tigers',
            filePath: `/home/user/Desktop/tigers.json`,
            absoultePath: true
        },
        people: {
            collections: ['students', 'teachers'],
            filePath: function(db, collection, type) {
                return `${db}/${collection}/${collection}.${type}`;
            }
        }
    },
    outDir: './backup'
};

await mongoExport(options);



SPECIFYING WHAT IS TO BE LOGGED BY THE FUNCTION

THIS WILL EXPORT ALL THE COLLECTIONS OF THE DATABASE. INSTEAD OF THE DEFAULT
BASE LOG, THE MONGOEXPORT COMMANDS AND THE MONGOEXPORT LOGS WILL BE LOGGED.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    logs: ['commands', 'mongoexport']
};

await mongoExport(options);


The log will be similar to this:



THIS WILL EXPORT ALL THE COLLECTIONS OF THE DATABASE. INSTEAD OF SHOWING THE
MONGOEXPORT LOGS IN THE END, IT WILL BE LOGGED IN REALTIME.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    logs: ['commands', 'mongoexport'],
    realtimeLog: true
};

await mongoExport(options);


THIS WILL EXPORT ALL THE COLLECTIONS OF THE DATABASE. INSTEAD OF THE DEFAULT
BASE LOG, THE FETCHED COLLECTIONS AND THE CORRECTLY EXPORTED COLLECTIONS ARE
LOGGED.

const { mongoExport } = require('mongoback');
const options = { 
    all: true,
    logs: ['expectedCollections', 'actualCollections']
};

await mongoExport(options);


The log will be similar to this:




API

The documentation site is: mongoback documentation

The documentation for development site is: mongoback dev documentation


MONGOEXPORT

Syntax:

mongoback.mongoExport(options)

Description:

The function to export collections from a mongodb. You can specify the mongodb
collection, the collections that will be exported, how they will be exported and
where. To understand well how to use it, it is recommended reading the Examples
above.

Parameters:

 * options: The options object of the mongoExport function.

Options parameters:

The Options object is the merge of other more-specific options objects, defined
below.

ConnectionOptions parameters:

The MongoDB connection options. They will define both the options of the
mongoexport command and the uri/MongoClientOptions of the connection used to
list databases and collections. Most of the properties are exactly the same of
the mongoexport options. Some are slightly modified to allow a more confortable
usage, without changing what will be passed as a mongoexport option. The default
value of the option does not corrispond with the mongoexport one. When there is
a value set to false or undefined, it means that the option is not added to the
mongoexport command, not that it is the default value of mongoexport. To support
the old versions of mongoexport, there are also the deprecated options.

 * uri: Default value: undefined. The uri of the MongoDB connection. If it is
   specified, the options host, port, password, username, srv,
   authenticationMechanism, authenticationDatabase will be set to undefined and
   ignored.
 * host: Default value: localhost. The host of the MongoDB connection. It can be
   a string or an array of ReplicaSet, objects with host and port keys. The
   property differs from the mongoexport one in which also an array of replica
   sets can be passed.
 * port: Default value: 27017. The port of the MongoDB connection.
 * username: Default value: undefined. The username of the MongoDB connection.
 * password: Default value: undefined. The password of the MongoDB connection.
 * authenticationDatabase: Default value: undefined. The authenticationDatabase
   of the MongoDB connection.
 * authenticationMechanism: Default value: undefined. The
   authenticationMechanism of the MongoDB connection.
 * srv: Default value: false. If the connection If the MongoDB connection uri is
   an srv. This property is not present in the mongoexport options, where the
   "+srv" can be added manually in the host option.
 * replicaSetName: Default value: undefined. The replicaSetName of the MongoDB
   connection. This property is not present in the mongoexport options, where
   the replica set name is passed in the uri options or in the host option.
 * ssl: Default value: false. If the MongoDB connection uses ssl or tls.
 * sslCAFile: Default value: undefined. Specifies the .pem file that contains
   both the TLS/SSL certificate and key.
 * sslPEMKeyFile: Default value: undefined. Specify the file name of the .pem
   file using relative or absolute paths.
 * sslPEMKeyPassword: Default value: undefined. Specifies the password to
   de-crypt the certificate-key file (i.e. --sslPEMKeyFile). Use the
   --sslPEMKeyPassword option only if the certificate-key file is encrypted. In
   all cases, the mongoexport will redact the password from all logging and
   reporting output.
 * sslCRLFile: Default value: undefined. Specifies the .pem file that contains
   the Certificate Revocation List. Specify the file name of the .pem file using
   relative or absolute paths.
 * sslFIPSMode: Default value: false. Directs the mongoexport to use the FIPS
   mode of the installed OpenSSL library. Your system must have a FIPS compliant
   OpenSSL library to use the --sslFIPSMode option. NB: Deprecated option of
   mongoexport.
 * sslAllowInvalidCertificates: Default value: false. Bypasses the validation
   checks for server certificates and allows the use of invalid certificates.
   When using the allowInvalidCertificates setting, MongoDB logs as a warning
   the use of the invalid certificate.
 * sslAllowInvalidHostnames: Default value: false. Disables the validation of
   the hostnames in TLS/SSL certificates. Allows mongoexport to connect to
   MongoDB instances even if the hostname in their certificates do not match the
   specified hostname.
 * gssapiServiceName: Default value: undefined. Specify the name of the service
   using GSSAPI/Kerberos. Only required if the service does not use the default
   name of mongodb.
 * gssapiHostName: Default value: undefined. Specify the hostname of a service
   using GSSAPI/Kerberos. Only required if the hostname of a machine does not
   match the hostname resolved by DNS.
 * slaveOk: Default value: false. Sets the Read Preference to nearest, allowing
   mongoexport to read data from secondary replica set members. NB: Deprecated
   option of mongoexport
 * readPreference: Default value: undefined. Specify the read preference for
   mongoexport. It can be a string such as 'primary' or 'secondary' or an
   object. If you want to pass the json object as a string, you must manually
   include it in apixes.
 * journal: Default value: false. Allows mongoexport operations to access the
   durability journal to ensure that the export is in a valid state. This option
   is only relevant when specifying the --dbpath option. NB: Deprecated option
   of mongoexport
 * ipv6: Default value: false. Enables IPv6 support that allows mongoexport to
   connect to the MongoDB instance using an IPv6 network. All MongoDB programs
   and processes, including mongoexport, disable IPv6 support by default. NB:
   Deprecated option of mongoexport
 * dbpath: Default value: undefined. Specifies the directory of the MongoDB data
   files. If used, the --dbpath option enables mongoexport to attach directly to
   local data files and insert the data without the mongod. To run with
   --dbpath, mongoexport needs to lock access to the data directory: as a
   result, no mongod can access the same path while the process runs. NB:
   Deprecated option of mongoexport
 * directoryperdb: Default value: false. Use the --directoryperdb in conjunction
   with the corresponding option to mongod, which allows mongoexport to export
   data from MongoDB instances that have every database’s files saved in
   discrete directories on the disk. This option is only relevant when
   specifying the --dbpath option. NB: Deprecated option of mongoexport.

ExportedOptions parameters:

The exported options interface. It contains the options about what should be
exported and what to do if it is not exported correctly.

 * all: Default value: false. If all the collections of every database will be
   exported.
 * databases: Default value: []. The databases that will be exported. All the
   collections of a database will be exported. Eventual exporting options passed
   to this option will overwrite the default ones.
 * collections: Default value: []. The collections that will be exported.
   Eventual exporting options passed to this option will overwrite the default
   ones and the ones in the "database" option.
 * systemCollections: Default value: false. If also system collections will be
   exported.
 * throwIfLackOfPermissions: Default value: false. If for permissions causes
   there is an error while listing databases or collections of the MongoDB, an
   error will be thrown. If the value is false, the databases and collections
   that cannot be listed will be ignored and not be exported. NB: Actually all
   the errors that happen while listing databases or collections, not only the
   permission ones, will be thrown.
 * warnIfLackOfPermissions: Default value: false. If for permissions causes
   there is an error while listing databases or collections of the MongoDB, a
   warning message will be logged. NB: Actually all the errors that happen while
   listing databases or collections, not only the permission ones, will be
   warned.
 * throwIfOneFails: Default value: false. If the mongoexport of a collection
   fails, an error will be thrown. If the value is false, the result of the
   function will have code PARTIAL(= 1), specifying that not all the expected
   collections were exported.
 * warnIfOneFails: Default value: false. If the mongoexport of a collection
   fails, a warning will be logged.

ExportingOptions parameters:

The options about how the collections will be exported. They will define both
the options of the mongoexport command and others not regarding it. See the
mongoexport official documentation to further information. It is divided in
ExtendedExportingOptions (not regarding mongoexport) and
StandardExportingOptions (regarding mongoexport).

ExtendedExportingOptions parameters

Options that specify how will the options be exported and are not about the
mongoexport options.

 * prependDbName: Default value: undefined. If the file name will be prepended
   by the database of the collection. The format is:
   "database_filename.extension". When undefined, if the outType is 'deep' the
   file name is not prepended while if the outType is 'flat' it is prepended
 * fileName: Default value: undefined. A string or a function returning the name
   of the file of the exported collection.
 * filePath: Default value: undefined. A string or a function returning the path
   of the file of the exported collection.
 * absolutePath: Default value: false. If the filePath value is absolute and not
   relative to the outDir option.

StandardExportingOptions parameters

The exporting options regarding the mongoexport command. Most of the properties
are exactly the same of the mongoexport options. Some are slightly modified to
allow a more confortable usage, without changing what will be passed as a
mongoexport option. The default value of the option does not corrispond with the
mongoexport one. When there is a value set to false or undefined, it means that
the option is not added to the mongoexport command, not that it is the default
value of mongoexport. To support the old versions of mongoexport, there are also
the deprecated options. See the mongoexport official documentation to further
information.

 * quiet: Default value: false. Runs mongoexport in a quiet mode that attempts
   to limit the amount of output.
 * verbose: Default value: false. Increases the amount of internal reporting
   returned on standard output or in log files. Increase the verbosity with the
   -v form by including the option multiple times, (e.g. -vvvvv.) If the value
   is true, the option '--verbose' will be added. If it is a number, it will be
   the number of v that will be put in the command. (e.g. 3 gives -vvv).
 * type: Default value: undefined. Accepted values: "json" or "csv". Specifies
   the file type to export. Specify csv for CSV format or json for JSON format.
   If you specify csv, then you must also use either the --fields or the
   --fieldFile option to declare the fields to export from the collection.
 * jsonFormat: Default value: undefined. Accepted values: "realaxed" or
   "canonical". Modifies the output to use either canonical or relaxed mode of
   the MongoDB Extended JSON (v2) format.
 * jsonArray: Default value: false. Modifies the output of mongoexport to write
   the entire contents of the export as a single JSON array. By default
   mongoexport writes data using one JSON document for every MongoDB document.
 * pretty: Default value: false. Outputs documents in a pretty-printed format
   JSON.
 * query: Default value: undefined. Provides a query as a JSON document
   (enclosed in quotes) to return matching documents in the export. You must
   enclose the query document in single quotes ('{ ... }') to ensure that it
   does not interact with your shell environment. Starting in MongoDB 4.2, the
   query must be in Extended JSON v2 format (either relaxed or canonical/strict
   mode), including enclosing the field names and operators in quotes. You can
   pass the argument either as a string (it will automatically be included in
   apixes) or as an object.
 * fields: Default value: undefined. Specifies a field or fields to include in
   the export. Use a comma separated list of fields to specify multiple fields.
   If any of your field names include white space, use quotation marks to
   enclose the field list. For example, if you wished to export two fields,
   phone and user number, you would specify --fields "phone,user number". For
   csv output formats, mongoexport includes only the specified field(s), and the
   specified field(s) can be a field within a sub-document. For JSON output
   formats, mongoexport includes only the specified field(s) and the _id field,
   and if the specified field(s) is a field within a sub-document, the
   mongoexport includes the sub-document with all its fields, not just the
   specified field within the document. You can pass either a string ora an
   array of strings. The fields are automatically included in quotes to support
   whitespaces.
 * fieldFile: Default value: undefined. An alternative to --fields. The
   --fieldFile option allows you to specify in a file the field or fields to
   include in the export and is only valid with the --type option with value
   csv. The file must have only one field per line, and the line(s) must end
   with the LF character (0x0A).
 * noHeaderLine: Default value: false. By default, mongoexport includes the
   exported field names as the first line in a CSV output. --noHeaderLine
   directs mongoexport to export the data without the list of field names.
   --noHeaderLine is only valid with the --type option with value csv.
 * skip: Default value: undefined. Use --skip to control where mongoexport
   begins exporting documents. See skip() for information about the underlying
   operation.
 * limit: Default value: undefined. Specifies a maximum number of documents to
   include in the export. See limit() for information about the underlying
   operation.
 * sort: Default value: undefined. Specifies an ordering for exported results.
   If an index does not exist that can support the sort operation, the results
   must be less than 32 megabytes. You can pass the argument either as a string
   (it will automatically be included in apixes) or as an object.
 * forceTableScan: Default value: false. Forces mongoexport to scan the data
   store directly instead of traversing the _id field index. Use
   --forceTableScan to skip the index.

LogOptions parameters:

The options about what will be logged during the function execution

 * silent: Default value: false. If nothing will be logged.
 * log: Default value: ['base']. The log modes. If there is more than a mode,
   they must be specified in an array.Possible values: base: During exporting,
   the databases and collections are shown with a spinner, command: Logs the
   mongoexport command, mongoexport: Logs the mongoexport log,
   expectedCollections: Logs the object containing the collections expected to
   be exported, actualCollections: Logs the object containing the collections
   that have actually been exported
 * realtimeLog: Default value: false. If the mongoexport log is specified, it
   will show the actual log generated by mongoexport under the hood. If this
   option is true, this log will be shown in realtime, during the exporting
   operation. If it is false, it will be shown in the end of the exporting
   operation.

OutOptions parameters:

The options about the output location and the result of the function

 * outDir: Default value: './exported'. The path were the exported collections
   will be saved.
 * outType: Default value: 'deep'. The type of the saving location. It can be:
   'deep': A folder will be created for each database. Each folder contains the
   exported collections of that database with the collection name as file name
   'flat': No folder will be created for each database. A file whose name is the
   exported collection name prepended by its database name (if prependDBName is
   not false) will be created for each exported collection
 * detailedResult: Default value: false. If the result will contain also the
   exporting options of the expected/actual collections.


PROJECT STRUCTURE

Made with dree.

mongoback
 ├─> source
 │ ├─> bin
 │   ├─> lib
 │   │   ├─> errors
 │   │   ├── index.ts
 │   │   ├─> interfaces
 │   │   └─> utils
 │   └── tsconfig.json
 ├─> test
 │   ├─> complete
 │   ├─> getCommand
 │   ├─> getMongoConnection
 │   ├─> mock
 │   ├── test.ts
 │   ├── tsconfig.json
 │   └─> utils
 ├─> dist
 │   ├─> source
 │   └─> test
 ├─> docs
 │   ├─> assets
 │   └─> tree
 │       ├── dree.config.json
 │       └── tree.txt
 ├── package-lock.json
 ├── package.json
 └── .eslintrc.js



BUILD

To build the module make sure you have Typescript installed or install the dev
dependencies. After this, run:

$ npm run transpile


The source folder will be compiled in the dist folder.


DEV

Make sure you have the dev dependencies installed.

To lint the code go to the package root in your CLI and run

$ npm run lint


To run tests go to the package root in your CLI and run

$ npm run db:populate
$ npm test


Note: Running tests will delete permanently your MongoDB data. Do not do it if
you have important data on it.

 * Exports

 * AuthenticationMechanism
 * ExportResultCode
 * MongoBackDatabaseError
 * MongoBackError
 * MongoBackExportingError
 * MongoBackMongoexportNotInstalledError
 * ConnectionOptions
 * DetailedExportSchema
 * ExportResult
 * ExportSchema
 * ExportedOptions
 * ExtendedExportingOptions
 * LogOptions
 * OutOptions
 * ReplicaSet
 * SpecificCollections
 * StandardExportingOptions
 * Collection
 * Collections
 * Database
 * Databases
 * DetailedCollection
 * DetailedDatabase
 * DetailedGeneralCollections
 * ExportingCollection
 * ExportingFileName
 * ExportingFilePath
 * ExportingOptions
 * GeneralCollection
 * GeneralCollections
 * LambdaCollection
 * LambdaDatabase
 * LogType
 * LogTypes
 * Options
 * instanceOfGeneralCollection
 * instanceOfLambdaDatabase
 * instanceofLambdaCollection
 * mongoExport


LEGEND

 * Constructor
 * Property

 * Property


SETTINGS

Theme OSLightDark

Generated using TypeDoc