mongoose-seed-csv

0.0.4 • Public • Published

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
  • callback

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)
 */

Dependencies

Package Sidebar

Install

npm i mongoose-seed-csv

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

5.6 kB

Total Files

4

Last publish

Collaborators

  • noizbuster