mongoimport

1.0.6 • Public • Published

build status

mongoimport

import JSON to mongodb, associate with sofish/log2json to manage nginx logs.

$ npm install mongoimport --save

Usage

Install the package with npm, and bring it to your project.

var mi = require('mongoimport');
mi(config);

Follow the codes below to create a config object:

var config = {
fields: [],                     // {array} data to import
db: 'name',                     // {string} name of db
collection: 'collection'        // {string|function} name of collection, or use a function to
                                //  return a name, accept one param - [fields] the fields to import
 
// they're options
host: 'localhost:27017',        // {string} [optional] by default is 27017
username: 'sofish',             // {string} [optional]
password: '***'                 // {string} [optional]
callback: (err, db) => {}       // {function} [optional]
};

Test

Simply run npm test to see what happens.

Readme

Keywords

Package Sidebar

Install

npm i mongoimport

Weekly Downloads

73

Version

1.0.6

License

MIT

Last publish

Collaborators

  • sofish