Comparing version
@@ -18,5 +18,5 @@ 'use strict' | ||
'export': function (collection) { | ||
if (collection) this.config.collection = collection | ||
return SPAWN('mongoexport', QUERY['export'](this.config).split(' ')) | ||
'export': function (col) { | ||
let options = col ? Object.assign({}, this.config, {'collection': col}) : this.config | ||
return SPAWN('mongoexport', QUERY['export'](options).split(' ')) | ||
}, | ||
@@ -23,0 +23,0 @@ |
{ | ||
"name": "spawngo", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Spawn a child process for mongoimport/export", | ||
@@ -30,5 +30,8 @@ "engines": { | ||
"spawn", | ||
"mongoimport", | ||
"mongoexport", | ||
"child_process", | ||
"json", | ||
"csv" | ||
"csv", | ||
"otc" | ||
], | ||
@@ -35,0 +38,0 @@ "author": "Otter the Cat", |
@@ -34,4 +34,8 @@ # spawngo | ||
Exporting is nearly identical to the above, but instead of `import()`, you would call `export()` | ||
Exporting is nearly identical to the above, but instead of `import()`, you would call `export()` to export the collection as defined when *spawngo* was instantiated, or updated using `.set()` | ||
```javascript | ||
let childProcess = spawngo.export() | ||
``` | ||
If you wish to export a different collection, but not alter the internal configurated collection, you can pass a string of the target collection,: | ||
```javascript | ||
let childProcess = spawngo.export('collectionName') | ||
@@ -65,4 +69,8 @@ ``` | ||
*collection (String)*: Name of the collection to export. The exported `json` file will be named after the collection (i.e `collectionName.json`). | ||
*collection (String [optional])*: Name of the collection to export. The exported `json` file will be named after the collection (i.e `collectionName.json`). | ||
The `string` aurgument is optional. Not passing a string will use the collect as defined internally either via the `constructor` settings, or from using `.set()`. | ||
Note that passsing a collection string in this manner will *NOT* alter the internal configuration. | ||
*returns*: ChildProcess of the spawned query. | ||
@@ -69,0 +77,0 @@ |
8046
8.69%82
10.81%