Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongo-seeding-cli

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-seeding-cli

The ultimate command line tool for populating your MongoDB database.

  • 4.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
586
decreased by-8.58%
Maintainers
1
Weekly downloads
 
Created
Source

Mongo Seeding

Mongo Seeding CLI

npm version Build Status codecov David David install size

The ultimate CLI tool for populating your MongoDB database :rocket:

Define MongoDB documents in JSON, JavaScript or even TypeScript file(s). Import them with command line interface.

Installation

To install the app, run the following command:

npm install -g mongo-seeding-cli

Usage

  1. Follow the tutorial to define documents and collections to import.

  2. In order to seed your database with data from current directory using default configuration, run the following command:

    seed
    
  3. You can specify custom settings with command line parameters. The following example imports data from ./example/data directory using MongoDB connection URI mongodb://127.0.0.1:27017/mydb with option to drop database before import:

    seed -u 'mongodb://127.0.0.1:27017/mydb' --drop-database ./example/data
    

    You can also use environmental variables to configure the CLI. For example:

    DB_URI='mongodb://127.0.0.1:27017/mydb' DROP_DATABASE=true seed ./example/data
    

    Full configuration options are described in Configuration section.

Configuration

You can configure data import with command line parameters or environmental variables.

Note: Command line parameters have always a higher priority over environmental variables.

Command line parameters

You can use the following parameters while using seed tool:

NameDefault ValueDescription
{PATH}current directoryPath to directory containing import data
--db-uri {URI} or -u {URI}undefinedIf defined, the URI will be used for establishing connection to database, ignoring values defined via other db-* parameters (e.g. db-name, db-host, etc.)
--db-protocol {DB_PROTOCOL}mongodbMongoDB database protocol
--db-host {DB_HOST}127.0.0.1MongoDB database host
--db-port {DB_PORT}27017MongoDB database port
--db-name {DB_NAME}databaseName of the database
--db-username {DB_USERNAME}undefinedUsername for connecting with database that requires authentication
--db-password {DB_PASSWORD}undefinedPassword for connecting with database that requires authentication
--db-optionsundefinedMongoDB connection options in a form of multiple {key}={value} values, separated by semicolon. For example: ssl=true;maxPoolSize=50
--drop-databasefalseDrops entire database before data import
--drop-collectionsfalseDrops every collection which is being imported
--remove-all-documentsfalseDelete all documents from every collection that is being imported
--replace-idfalseReplaces id property with _id for every document during data import
--set-timestampsfalseSets createdAt and updatedAt timestamps for every document during data import
--reconnect-timeout10000Maximum time in milliseconds of waiting for successful MongoDB connection
--ejson-parse-canonical-modefalseEnables EJSON Canonical Mode for all parsed .json files. By default the EJSON Relaxed mode is enabled.
--transpile-onlyfalseDisables type checking on TypeScript files import. This option vastly improves performance of TypeScript data import
--silent or -sfalseDisables printing logging of Mongo Seeding status to standard output
--help or -hn/aHelp

Environmental variables

You can use the following environmental variables while using seed tool:

NameDefault ValueDescription
DB_URIundefinedIf defined, the URI is used for establishing connection to database, ignoring values given in DB_* environmental variables (e.g. DB_HOST, DB_PORT, etc.).
DB_HOST127.0.0.1MongoDB database host
DB_PORT27017MongoDB database port
DB_NAMEdatabaseName of the database
DB_USERNAMEundefinedUsername for connecting with database that requires authentication
DB_PASSWORDundefinedPassword for connecting with database that requires authentication
DB_OPTIONSundefinedMongoDB connection options in a form of multiple {key}={value} values, separated by semicolon. For example: ssl=true;maxPoolSize=50.
DROP_DATABASEfalseDrops entire database before data import
DROP_COLLECTIONSfalseDrops every collection which is being imported
REMOVE_ALL_DOCUMENTSfalseDelete all documents from every collection that is being imported
REPLACE_IDfalseReplaces id property with _id for every document during import; useful for ORMs
SET_TIMESTAMPSfalseSets createdAt and updatedAt timestamps for every document during data import
RECONNECT_TIMEOUT10000Maximum time in milliseconds of waiting for successful MongoDB connection
EJSON_PARSE_CANONICAL_MODEfalseEnables EJSON Canonical Mode for all parsed .json files. By default the EJSON Relaxed mode is enabled.
TRANSPILE_ONLYfalseDisables type checking on TypeScript files import. This option vastly improves performance of TypeScript data import
SILENTfalseDisables printing logging of Mongo Seeding status to standard output

Keywords

FAQs

Package last updated on 07 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc