mongoose-seed-csv
v0.0.4
Published
Seed data from *.csv files for Mongoose
Downloads
36
Maintainers
Readme
mongoose-seed-csv
mongoose-seed-csv is a wrapper for mongoose-seed that will parse data from csv files
Usage
const seeder = require('mongoose-seed-csv');
seeder.populateFromCSV(
[
'./test/location.csv',
{path: './test/map.csv', model: 'Map', parseOptions: {columns: true}}
],
{columns: true, parseDeep: true},
function(){
seeder.disconnect();
});
Methods
seeder.populateFromCSV(csvEntryArray, [csvParseOptions], [callback])
- csvEntryArray: [string(filepath) || CSV_Entry]
- you can you both filepath and CSV_Entry Object and even mixed
- csvParseOptions
- see: options for cvs-parse
- +
parseDeep
: if true, the parser try to parse each value as JSON
- callback
- same callback as in mongoose-seed's populateModels
CSV_EntryObject
/**
* @typedef {object} CSV_Entry
* @property {string} path - csv file path
* @property {string} [model] - model name
* @property {string} [parseOptions] - individual parse option (it will override csvParseOption)
*/