Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 847 Bytes

README.md

File metadata and controls

43 lines (36 loc) · 847 Bytes

csv-differ

This plugin parses a CSV and outputs an item-by-item diff against a collection of objects. It will accept both File and String arguments as CSV.

Example usage:

Initialize service

const service = await detectChanges(
  csvFileOrString,
   {
    records: [{ slug: 'test', firstName: 'Nate' }],
    identifier: 'slug',
    updateFunction(record, changes) {
      $axios.patch(apiUrl(record.slug), changes)
    }
  }
)

Get all records with detected changes

service.changedRecords
// => [
// {
// "record":{"slug":"test","firstName":"Aaron"},
// "diff":{"added":{},"deleted":{},"updated":{"firstName":"Aaron"}}
// },
// ..
// ]

Update a single record (assuming you provided a function)

service.update('test')

Update all changed records

service.updateAll()