How to use the cassandra-driver.mapping function in cassandra-driver

To help you get started, we’ve selected a few cassandra-driver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datastax / nodejs-driver / examples / mapper / mapper-insert-retrieve.js View on Github external
"use strict";
const cassandra = require('cassandra-driver');
const Uuid = cassandra.types.Uuid;
const UnderscoreCqlToCamelCaseMappings = cassandra.mapping.UnderscoreCqlToCamelCaseMappings;

const client = new cassandra.Client({ contactPoints: ['127.0.0.1'], localDataCenter: 'datacenter1' });

const mapper = new cassandra.mapping.Mapper(client, { models: {
  'Video': {
    tables: ['videos', 'user_videos', 'latest_videos'],
    keyspace: 'examples',
    columns: {
      'videoid': 'videoId',
      'userid': 'userId'
    },
    mappings: new UnderscoreCqlToCamelCaseMappings()
  }
}});

const videoId = Uuid.random();
const userId = Uuid.random();

/**
 * Inserts an object and retrieves it using the Mapper.
github datastax / nodejs-driver / examples / mapper / mapper-insert-retrieve.js View on Github external
"use strict";
const cassandra = require('cassandra-driver');
const Uuid = cassandra.types.Uuid;
const UnderscoreCqlToCamelCaseMappings = cassandra.mapping.UnderscoreCqlToCamelCaseMappings;

const client = new cassandra.Client({ contactPoints: ['127.0.0.1'], localDataCenter: 'datacenter1' });

const mapper = new cassandra.mapping.Mapper(client, { models: {
  'Video': {
    tables: ['videos', 'user_videos', 'latest_videos'],
    keyspace: 'examples',
    columns: {
      'videoid': 'videoId',
      'userid': 'userId'
    },
    mappings: new UnderscoreCqlToCamelCaseMappings()
  }
}});

const videoId = Uuid.random();