Constructor
new Schema(columns, options)
Parameters:
Name | Type | Description |
---|---|---|
columns |
object | A list of key:values representative of field:type |
options |
object | A list of schema specific options, primary/composite keys |
Example
Create a new Schema Object
var testSchema = new Cassandra.Schema({
id: {default: Cassandra.uuid, required: true},
name: 'text',
age: 'int',
username: 'text'
}, {
primaryKeys: ['username'],
views: {
byName: {
primaryKeys: ['name'],//, 'username'], is implied
orderBy: {
name: 'desc',
username: 'asc'
}
}
}
});
Methods
_prepareColumns(columns)
Prepare Schema columns and validate their types this will set the schema's
columns array list and set the "default", "required", and "type" settings
for the columns, populating schema.columns,
Cassandra.Schema.required, Cassandra.Schema.defaults.
This will check the list of types against the Cassandra.types.dataTypes
Parameters:
Name | Type | Description |
---|---|---|
columns |
object | A list of key:values representative of field:type |
- Source:
- See:
_qualifyPrimaryKeys(primaryKeys)
Validates keys against the prepared model
Parameters:
Name | Type | Description |
---|---|---|
primaryKeys |
array | an array of primary keys |
_qualifyViews(views) → {undefined}
Validates each view defined by the schema's options
Parameters:
Name | Type | Description |
---|---|---|
views |
object | an object of defined views |
Throws:
Error - invalid view settings
Returns:
- Type
- undefined
qualifyView(viewName, viewConfig) → {boolean}
Qualify a single view by name
Parameters:
Name | Type | Description |
---|---|---|
viewName |
string | the name of the materialized view, this will be convert to |
viewConfig |
object | a valid view configuration |
Throws:
Error - invalid view settings
Returns:
true - if successful
- Type
- boolean