Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-cassandra

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-cassandra - npm Package Compare versions

Comparing version 0.2.5 to 0.3.1

32

lib/orm/base_model.js

@@ -295,3 +295,6 @@ var util = require('util'),

field_type = schemer.get_field_type(schema, k);
rows.push(util.format('"%s" %s',k,field_type));
if(schema.fields[k].typeDef) {
rows.push(util.format('"%s" %s%s',k,field_type,schema.fields[k].typeDef));
}
else rows.push(util.format('"%s" %s',k,field_type));
}

@@ -326,3 +329,3 @@

var query = util.format(
"CREATE INDEX IF NOT EXISTS ON %s (%s);",
'CREATE INDEX IF NOT EXISTS ON "%s" ("%s");',
table_name,

@@ -344,3 +347,3 @@ index_name

var query = util.format(
"CREATE CUSTOM INDEX IF NOT EXISTS ON %s (%s) USING '%s'",
'CREATE CUSTOM INDEX IF NOT EXISTS ON "%s" ("%s") USING \'%s\'',
table_name,

@@ -428,3 +431,2 @@ custom_index.on,

*/
//BaseModel._execute_table_query = BaseModel._execute_definition_query;
BaseModel._execute_table_query = function(query, params, callback){

@@ -543,3 +545,3 @@

query_relations.push( util.format(
'%s %s %s',
'"%s" %s %s',
k,op,this._get_db_value_expression(k,first_value)

@@ -588,3 +590,3 @@ ));

order_keys.push(util.format(
'%s %s',
'"%s" %s',
order_fields[i], cql_orderdir[order_item_keys[0]]

@@ -605,5 +607,5 @@ ));

var select = ['*'];
if(options.select && lodash.isArray(options.select)) {
select = options.select;
var select = '*';
if(options.select && lodash.isArray(options.select) && options.select.length > 0) {
select = '"' + options.select.join('","') + '"';
}

@@ -767,3 +769,3 @@

for(var key in update_values) {
update_clause_array.push(key + "=" + this._get_db_value_expression(key,update_values[key]));
update_clause_array.push('"' + key + '"=' + this._get_db_value_expression(key,update_values[key]));
}

@@ -786,3 +788,3 @@

for(var key in options.conditions) {
update_conditions_array.push(key + "=" + this._get_db_value_expression(key,options.conditions[key]));
update_conditions_array.push('"' + key + '"=' + this._get_db_value_expression(key,options.conditions[key]));
}

@@ -977,3 +979,3 @@ query += ' IF ' + update_conditions_array.join(' AND ');

identifiers.push(f);
identifiers.push('"'+f+'"');

@@ -989,4 +991,4 @@ try{

var query = util.format(
"INSERT INTO %s ( %s ) VALUES ( %s )",
properties.qualified_table_name,
'INSERT INTO "%s" ( %s ) VALUES ( %s )',
properties.table_name,
identifiers.join(" , "),

@@ -1066,2 +1068,2 @@ values.join(" , ")

* @typedef {Object} BaseModel~save_options
*/
*/

@@ -7,2 +7,10 @@ var check = require('check-types'),

validators.is_array = function (obj){
return check.array(obj);
};
validators.is_object = function (obj){
return check.object(obj);
};
validators.is_long = function (obj){

@@ -73,3 +81,6 @@ return isNaN(obj) === false;

"varchar" : {validator : validators.is_string, dbvalidator : "org.apache.cassandra.db.marshal.UTF8Type"},
"varint" : {validator : validators.is_integer, dbvalidator : "org.apache.cassandra.db.marshal.IntegerType"}
"varint" : {validator : validators.is_integer, dbvalidator : "org.apache.cassandra.db.marshal.IntegerType"},
"map" : {validator : validators.is_string, dbvalidator : "org.apache.cassandra.db.marshal.MapType"},
"list" : {validator : validators.is_string, dbvalidator : "org.apache.cassandra.db.marshal.ListType"},
"set" : {validator : validators.is_string, dbvalidator : "org.apache.cassandra.db.marshal.SetType"}
};

@@ -89,4 +100,7 @@

TYPE_MAP.find_type_by_dbvalidator = function(val){
//decompose composite types
var decomposed = val ? val.split(/[(,)]/) : [''];
for(var t in this){
if (this[t].dbvalidator == val)
if (this[t].dbvalidator == decomposed[0])
return t;

@@ -97,2 +111,2 @@ }

module.exports = TYPE_MAP;
module.exports = TYPE_MAP;
{
"name": "express-cassandra",
"version": "0.2.5",
"version": "0.3.1",
"dependencies": {
"async": "^1.0.0",
"check-types": "^1.4.0",
"cassandra-driver": "^2.1.0",
"cassandra-driver": "~2.1.0",
"lodash": "^3.9.3"

@@ -40,4 +40,3 @@ },

],
"homepage": "https://github.com/masumsoft/express-cassandra",
"engine": "node >= 0.10.x"
}

@@ -165,2 +165,53 @@ express-cassandra

### Support for Composite Data Types
Cassandra composite data types (`map`, `list` & `set`) are supported in model schema definitions. An additional `typeDef` attribute is used to define the composite type.
```js
module.exports = {
"fields": {
info: {
type: "map",
typeDef: "<varchar, text>"
}
}
}
```
When saving or updating composite types, use the string representation of the value like the following:
```
var person = new models.instance.Person({
info: "{'key1':'val1','key2': 'val2'}"
});
person.save(function(err){
});
```
You may also use composite expressions supported by cassandra like the following:
```
models.instance.Dictionary.update({},{
info: "info + {'hello':'world'}"
},{},function(err){});
```
## Virtual fields

@@ -167,0 +218,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc