https://github.com/sofish/mongoimport
import JSON to mongo collection
https://github.com/sofish/mongoimport
Last synced: 5 months ago
JSON representation
import JSON to mongo collection
- Host: GitHub
- URL: https://github.com/sofish/mongoimport
- Owner: sofish
- License: mit
- Created: 2015-11-15T09:57:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-04-10T08:59:48.000Z (over 8 years ago)
- Last Synced: 2025-04-06T06:07:02.245Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 11
- Watchers: 3
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# mongoimport
import JSON to mongodb, associate with [sofish/log2json](https://github.com/sofish/log2json) to manage nginx logs.
```php
$ npm install mongoimport --save
```
## Usage
Install the package with npm, and bring it to your project.
```js
var mi = require('mongoimport');
mi(config);
```
Follow the codes below to create a config object:
```js
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.