Constructor
new Mapper(client, optionsopt)
Creates a new instance of Mapper.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
client |
Client | The Client instance to use to execute the queries and fetch the metadata. |
|
options |
MappingOptions |
<optional> |
The MappingOptions containing the information of the models and table mappings. |
- Source:
Examples
Creating a Mapper instance with some options for the model 'User'
const mappingOptions = {
models: {
'User': {
tables: ['users'],
mappings: new UnderscoreCqlToCamelCaseMappings(),
columnNames: {
'userid': 'id'
}
}
}
};
const mapper = new Mapper(client, mappingOptions);
Creating a Mapper instance with other possible options for a model
const mappingOptions = {
models: {
'Video': {
tables: ['videos', 'user_videos', 'latest_videos', { name: 'my_videos_view', isView: true }],
mappings: new UnderscoreCqlToCamelCaseMappings(),
columnNames: {
'videoid': 'id'
},
keyspace: 'ks1'
}
}
};
const mapper = new Mapper(client, mappingOptions);
Members
client :Client
The Client instance used to create this Mapper instance.
Type:
- Source:
Methods
batch(items, executionOptionsopt) → {Promise.<Result>}
Executes a batch of queries represented in the items.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
items |
Array.<ModelBatchItem> | |||||||||||||||||||||||||||
executionOptions |
Object | String |
<optional> |
An object containing the options to be used for the requests execution or a string representing the name of the execution profile. Properties
|
- Source:
Returns:
A Promise that resolves to a Result.
- Type
- Promise.<Result>
forModel(name) → {ModelMapper}
Gets a ModelMapper that is able to map documents of a certain model into CQL rows.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name to identify the model. Note that the name is case-sensitive. |
- Source:
Returns:
A ModelMapper instance.
- Type
- ModelMapper