How to use express-cassandra - 10 common examples

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
function init() {
    // Tell express-cassandra to use the models-directory, and
    // use bind() to load the models using cassandra configurations.
    var host = config.get('cassandra.host');
    var port = config.get('cassandra.port');
    var keyspace = config.get('cassandra.keyspace');
    models.setDirectory(__dirname + '/models').bind({
        clientOptions: {
            contactPoints: [host],
            protocolOptions: { port: port },
            keyspace: keyspace,
            queryOptions: { consistency: models.consistencies.one }
        },
        ormOptions: {
            // If your keyspace doesn't exist it will be created automatically
            // using the default replication strategy provided here.
            defaultReplicationStrategy: {
                class: 'SimpleStrategy',
                replication_factor: 1
            },
            //migration: 'safe',
            migration: 'alter',
            createKeyspace: false
        }
    },
        function (err) {
            if (err)
                console.log(err.message);
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
function init() {
    // Tell express-cassandra to use the models-directory, and
    // use bind() to load the models using cassandra configurations.
    var host = config.get('cassandra.host');
    var port = config.get('cassandra.port');
    var keyspace = config.get('cassandra.keyspace');
    models.setDirectory(__dirname + '/models').bind({
        clientOptions: {
            contactPoints: [host],
            protocolOptions: { port: port },
            keyspace: keyspace,
            queryOptions: { consistency: models.consistencies.one }
        },
        ormOptions: {
            // If your keyspace doesn't exist it will be created automatically
            // using the default replication strategy provided here.
            defaultReplicationStrategy: {
                class: 'SimpleStrategy',
                replication_factor: 1
            },
            //migration: 'safe',
            migration: 'alter',
            createKeyspace: false
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);
    });
}
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
function (err) {
            if (err)
                console.log(err.message);
            else
                console.log(models.timeuuid());
        }
    );
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
myinvestor.prototype.getDividendSummaries = function (exchangeName, callback) {
    models.instance.DividendSummary.find({
        g_exchange_name: exchangeName
    }, function (err, dividendSummaries) {
        callback(err, dividendSummaries);
    });
}
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
myinvestor.prototype.getChosenStocks = function (callback) {
    models.instance.ChosenStock.find({}, function (err, chosenStocks) {
        callback(err, chosenStocks);
    });
}
github Sunbird-Ed / SunbirdEd-portal / src / app / helpers / eCreds / cassandraUtil.js View on Github external
const insertData = (data, cb) => {
    const processId = models.uuid();
    data['id'] = _.toString(processId);
    const batch = new models.instance.bulk_upload_process(data);
    batch.save(err => {
        if (err) {
            cb(err, null);
        } else {
            cb(null, processId);
        }
    });
}
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
myinvestor.prototype.getStocks = function (exchangeName, callback) {
    models.instance.Stock.find({ exchange_name: exchangeName, $orderby: { '$asc': 'stock_symbol' }, }, function (err, stocks) {
        callback(err, stocks);
    });
}
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
myinvestor.prototype.getExchanges = function (callback) {
    models.instance.Exchange.find({}, function (err, exchanges) {
        callback(err, exchanges);
    });
}
github mengwangk / myInvestor / myInvestor-web / server / myinvestor.js View on Github external
myinvestor.prototype.getStockHistories = function (exchangeName, stockSymbol, callback) {
    models.instance.StockHistory.find({
        exchange_name: exchangeName,
        stock_symbol: stockSymbol,
        $orderby: { '$desc': ['stock_symbol', 'history_date'] }
    }, function (err, histories) {
        callback(err, histories);
    });
}

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 1 year ago

Package Health Score

51 / 100
Full package analysis