The 9.x release of Nano sees the following changes:
Most Nano users will be able to switch from Nano 8.x to Nano 9.x without modifying any code but as this is a major version release, some things have changed which may break your code - pay particular attention if you were using the “Follow” library or had configured custom logging.
The changes feed reader is completely rewritten and has a new interface:
const db = nano.db.use('mydb') db.changesReader.start({ batchSize: 50 }) .on('batch', (b) => { console.log('a batch of', b.length, 'changes has arrived'); }).on('seq', (s) => { console.log('sequence token', s); }).on('error', (e) => { console.error('error', e); })
const url = require('url') const logger = (data) => { // if this is a request if (typeof data.err === 'undefined') { const u = new url.URL(data.uri) console.log(data.method, u.pathname, data.qs) } else { // this is a response const prefix = data.err ? 'ERR' : 'OK' console.log(prefix, data.headers.statusCode, JSON.stringify(data.body).length) } } const nano = Nano({ url: process.env.COUCH_URL, log: logger })