Constructor
new Cassandra(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
object | an object defining how the connection will be made |
- Source:
Example
Connect to keyspace "testKeyspace" with options
var options = {
contactPoints: ['127.0.0.1'],
protocolOptions: {port: 9042},
keyspace: {
testkeyspace: {
durableWrites: true,
withReplication: {
class: 'SimpleStrategy',
replication_factor: 1
}
}
}
};
Classes
Members
(static) types
List of supported field types
- Source:
- See:
Methods
(static) connect(options, callback)
Shortcut constructor for new Cassandra -> connect()
Parameters:
Name | Type | Description |
---|---|---|
options |
object | an object defining how the connection will be made |
callback |
function | a callback to be called once connected or error |
- Source:
(static) timeuuid() → {TimeUuid}
Create a TimeUuid from the cassandra driver
- Source:
Returns:
- Type
- TimeUuid
(static) uuid() → {Uuid}
Create a Uuid from the cassandra driver
- Source:
Returns:
- Type
- Uuid
connect(callback)
Create a new connection to the database
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | a callback to be called once connected or error |
- Source:
maxTimeuuid() → {minTimeuuid}
Create a TimeUuid from the cassandra driver
- Source:
Returns:
an object to query maxTimeuuid
- Type
- minTimeuuid
minTimeuuid() → {minTimeuuid}
Create a TimeUuid from the cassandra driver
- Source:
Returns:
an object to query minTimeuuid
- Type
- minTimeuuid
model(name, schema, callback)
Create a new Cassandra.Model attached to a Cassandra.Schema
object on the named table, creating the table if it doesn't exist.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the table to attach the schema to |
schema |
object | the schema object |
callback |
function | a callback to be called once the table has been created |
- Source:
Example
Attach a schema to a model for querying
var cassandra = Cassandra.connect(...);
//create the ORM's schema
var testSchema = new Cassandra.Schema(...);
//attach the schema to the current cassandra instance
var testModel = cassandra.model('test', testSchema);
setKeyspace(callback)
Set the keyspace of the Cassandra instance (cassandra.keyspace)
creating it if it does not exist.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | a callback to be called on success or error |
- Source:
timeuuid() → {TimeUuid}
Create a TimeUuid from the cassandra driver
- Source:
Returns:
- Type
- TimeUuid
uuid() → {Uuid}
Create a Uuid from the cassandra driver
- Source:
Returns:
- Type
- Uuid