InsertBatcher

InsertBatcher

Class for batching database insert operations

Constructor

new InsertBatcher(db)

Description:
  • Create batcher instance

Source:
Example
let batcher = new InsertBatcher(common.db);
 batcher.insert("drill_eventsa8bb6a86cc8026768c0fbb8ed5689b386909ee5c", document);
Parameters:
Name Type Description
db Db

database object

Methods

addDb(name, connection)

Description:
  • Add another database to batch

Source:
Parameters:
Name Type Description
name string

name of the database

connection Db

MongoDB connection to that database

(async) flush(db, collection)

Description:
  • Writes data to database for specific collection

Source:
Parameters:
Name Type Description
db string

name of the database for which to write data

collection string

name of the collection for which to write data

flushAll() → {Promise}

Description:
  • Run all pending database queries

Source:
Returns:

promise

Type
Promise

insert(collection, doc, db)

Description:
  • Provide provide a document to insert into collection

Source:
Parameters:
Name Type Default Description
collection string

name of the collection where to update data

doc Object | Array

one document or array of documents to insert

db string countly

name of the database for which to write data

loadConfig()

Description:
  • Reloads server configs

Source:

schedule()

Description:
  • Schedule next flush

Source: