Mixin: AbstractModel

AbstractModel

AbstractModel class exposes basic CRUD ops for models. This class should not be instantiated by itself.
Source:

Methods

delete(queryObject, deleteObject, callback)

Delete columns or rows in the model's column family
Parameters:
Name Type Description
queryObject object an object representing column:value
deleteObject array deleteObject for selecting a subset of columns in select statements
callback function receives err, result
Source:
Example
var deleteObject = ['name']; //default "*"
var deleteObject = {
  usingTimestamp: Date.now()
};
var query = {
  name: 'foo',
  age: {
    $gt: 30
  }
};
cassandra.delete(query, deleteObject, (err, result) => console.log(err, result));
// DELETE name FROM <table> WHERE name = 'foo' AND age > 30

find(queryObject, projection, options, callback)

Find items in the model's column family
Parameters:
Name Type Description
queryObject object an object representing column:value
projection array projection for selecting a subset of columns in select statements
options object options for controlling your select statements
callback function receives err, result
Source:
Example
var projection = ['name']; //default "*"
var options = {
  allowFiltering: true,
  limit: 1
};
var query = {
  name: 'foo',
  age: {
    $gt: 30
  }
};
cassandra.find(query, projection, options, (err, result) => console.log(err, result));
// SELECT name FROM <table> WHERE name = 'foo' AND age > 30 LIMIT 1 ALLOW FILTERING

findOne()

Same as Cassandra.Model.find except forces a limit of 1 and always returns null or a row object
Source:

insert(queryObject, callback)

Insert items into the model's column family
Parameters:
Name Type Description
queryObject object an object representing column:value
callback function receives err, result
Source:

update(queryObject, updateObject, callback)

Update items in the model's column family
Parameters:
Name Type Description
queryObject object an object representing column:value
updateObject object an update object that uses $gt, $gte, $lt, $lte, $eq, $in, $contains, $containsKey
callback function receives err, result
Source:
Example
var query = {
  name: 'foo',
  age: {
    $in: [29,30,31]
  }
};
var update = {
  name: 'bar'
};
cassandra.find(query, projection, options, (err, result) => console.log(err, result));
// UPDATE <table> SET name='bar' WHERE name = 'foo' AND age IN (29, 30, 31)