NotifyBC
Home
Docs
Help
GitHub
Home
Docs
Help
GitHub
  • Getting Started

    • Welcome
    • Overview
    • Quick Start
    • Installation
    • Web Console
    • What's New
  • Configuration

    • Configuration Overview
    • Database
    • Admin IP List
    • Reverse Proxy IP Lists
    • HTTP Host
    • Internal HTTP Host
    • Email
    • SMS
    • Subscription
    • Notification
    • Node Roles
    • Cron Jobs
    • RSA Keys
    • Worker Process Count
    • Middleware
    • OIDC
    • TLS Certificates
    • Queue
    • Logging
  • API

    • API Overview
    • Subscription
    • Notification
    • Configuration
    • Administrator
    • Bounce
  • Miscellaneous

    • Health Check
    • Disaster Recovery
    • Memory Dump
    • Benchmarks
    • Bulk Import
    • Developer Notes
    • Upgrade Guide
  • Meta

    • Code of Conduct
    • Security Reporting
    • Acknowledgments

Bulk Import

To migrate subscriptions from other notification systems, you can use mongoimport. NotifyBC also provides a utility script to bulk import subscription data from a .csv file. To use the utility, you need

  • Software installed
    • Node.js
    • Git
  • Admin Access to a NotifyBC instance by adding your client ip to the Admin IP List
  • a csv file with header row matching subscription model schema. A sample csv file is provided. Compound fields (of object type) should be dot-flattened as shown in the sample for field confirmationRequest.sendRequest

To run the utility

git clone https://github.com/bcgov/NotifyBC.git
cd NotifyBC
npm i && npm run build
node dist/utils/bulk-import/subscription.js -a <api-url-prefix> -c <concurrency> <csv-file-path>

Here <csv-file-path> is the path to csv file and <api-url-prefix> is the NotifyBC api url prefix , default to http://localhost:3000/api.

The script parses the csv file and generates a HTTP post request for each row. The concurrency of HTTP request is controlled by option -c which is default to 10 if omitted. A successful run should output the number of rows imported without any error message

success row count = ***

Field Parsers

The utility script takes care of type conversion for built-in fields. If you need to import proprietary fields, by default the fields are imported as strings. To import non-string fields or manipulating json output, you need to define custom parsers in file src/utils/bulk-import/subscription.ts. For example, to parse myCustomIntegerField to integer, add in the colParser object

  colParser: {
    ...
    , myCustomIntegerField: (item, head, resultRow, row, colIdx) => {
      return parseInt(item)
    }
  }
Prev
Benchmarks
Next
Developer Notes