mongoose-to-csv-quotes
MongooseToCsvQuotes is a mongoose plugin that creates a CsvBuilder
instance for your Schema. Updated mongoose-to-csv
package that escapes commas by default. Only if options.show_headers is true, are headers put in first row.
Usage
const mongooseToCsvQuotes = var UserSchema = fullname: type: String email: type: String age: type: Number username: type: String; UserSchema; var User = mongoose; // Query and streamUser ; // Create stream from query resultsUser ; // Transform mongoose streamsUser ;
Installation
$ npm install mongoose-to-csv-quotes
Testing
Running tests requires a local mongodb server, and mocha. While most likely not a namespace issue, the test script will create a database __mongoose_to_csv_test__
, and drop the database when finished. You have been warned.
$ npm test
API
Schema.plugin(mongooseToCsvQuotes, options)
The options
argument is passed to the CsvBuilder
instance, please refer to
the Docs for more in-depth details. The only aditional property that can be included is the virutals
property.
The virtuals
have nothing to do with mongoose virtuals.
Schema.csvReadStream([docs])
Creates a csv formated read stream from query results.
- docs Array
Schema.csvTransformStream()
Transforms mongoose querystreams to csv formated streams.
Schema.findAndStreamCsv(query)
- query Object Mongoose query This is just a convenience method for:
Schema