How to use the cassandra-driver.types.Tuple 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 ahlwong / dakota-cassandra / lib / types.js View on Github external
exports.castValue = function(dakota, value) {
  
  // cassandra tuple
  if (value instanceof nmCassandraTypes.Tuple) {
    value = value.values();
  }
  
  // cassandra types
  if (value instanceof nmCassandraTypes.BigDecimal) {
    return value.toNumber();
  }
  else if (value instanceof nmCassandraTypes.InetAddress) {
    return value.toString();
  }
  else if (value instanceof nmCassandraTypes.Integer) {
    return value.toNumber();
  }
  else if (value instanceof nmCassandraTypes.LocalDate) {
    return value.toString();
  }
github ahlwong / dakota-cassandra / lib / types.js View on Github external
var parts = split(e.contents);
      if (e.keyword === 'frozen') {
        return exports.formatValueType(dakota, parts[0], value);
      }
      else if (e.keyword === 'map') {
        nm_.each(value, function(v, key) {
          key = exports.formatValueType(dakota, parts[0], key);
          value[key] = exports.formatValueType(dakota, parts[1], v);
        });
        return value;
      }
      else if (e.keyword === 'tuple') {
        value = nm_.map(parts, function(part, index) {
          return exports.formatValueType(dakota, part, value[index]);
        });
        return nmCassandraTypes.Tuple.fromArray(value);
      }
      else {
        value = nm_.map(value, function(v, index) {
          return exports.formatValueType(dakota, parts[0], v);
        });
        return value;
      }
    }
    else {
      return value;
    }
  }
  else if (exports.isUserDefinedType(dakota, type)) {
    return dakota.getUserDefinedType(type).formatValueTypeForSelf(value);
  }
  else {
github ahlwong / dakota-cassandra / lib / helpers.js View on Github external
exports.isTuple = function(x) {
  return nm_.isArray(x) || (x instanceof nmCassandraTypes.Tuple);
};