masumsoft / express-cassandra

Cassandra ORM/ODM/OGM for NodeJS with support for Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra & JanusGraph.
http://express-cassandra.readthedocs.io
GNU Lesser General Public License v3.0
227 stars 67 forks source link

How to set NetworkTopologyStrategy? #179

Closed mahfuzak08 closed 5 years ago

mahfuzak08 commented 5 years ago

How to set NetworkTopologyStrategy by using express-cassandra? Please give an example. Or, How to use multiple contact point { clientOptions: contactPoints: [ ], ...}...?

masumsoft commented 5 years ago

The documentation provides samples for SimpleStrategy and contactPoints. I hope that should be fairly simple to extend to use NetworkTopologyStrategy and multiple contact points like the following:

clientOptions: {
    contactPoints: ['host1.example.com', 'host2.example.com', 'host3.example.com'],
    keyspace: 'your_keyspace',
    queryOptions: { consistency: models.consistencies.quorum }
},
ormOptions: {
    defaultReplicationStrategy: {
      class: 'NetworkTopologyStrategy',
      dc1: 3,
      dc2: 2
    },
    migration: 'safe'
}
mahfuzak08 commented 5 years ago

Thank you so much.