How to use the express-cassandra.doBatch function in express-cassandra

To help you get started, we’ve selected a few express-cassandra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
myinvestor.prototype.saveChosenStocks = function (stocks, callback) {
    // http://express-cassandra.readthedocs.io/en/latest/batch/
    var queries = [];
    for (var i = 0; i < stocks.length; i++) {
        var stock = stocks[i];
        var chosenStock = new models.instance.ChosenStock({
            category: stock.category,
            exchange_name: stock.exchange_name,
            stock_symbol: stock.stock_symbol
        }); 
        var saveQuery = chosenStock.save({ return_query: true });      
        queries.push(saveQuery);
    }

    models.doBatch(queries, function (err) {
        callback(err, stocks.length);
    });
}

express-cassandra

Cassandra Object Models (ORM/ODM/OGM) for NodeJS with support for Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra & JanusGraph.

LGPL-3.0
Latest version published 3 months ago

Package Health Score

66 / 100
Full package analysis