express-cassandra
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -56,2 +56,5 @@ var util = require('util'); | ||
}, | ||
'model.update.dberror': { | ||
msg: 'Error during update query on DB -> %s' | ||
}, | ||
'model.delete.dberror': { | ||
@@ -115,2 +118,2 @@ msg: 'Error during delete query on DB -> %s' | ||
module.exports = build_error; | ||
module.exports = build_error; |
@@ -472,3 +472,3 @@ var util = require('util'), | ||
if(fieldvalue instanceof Array){ | ||
if(fieldvalue instanceof Array && fieldtype!='list' && fieldtype!='set'){ | ||
var val = fieldvalue.map(function(v){ | ||
@@ -499,2 +499,23 @@ return this._get_db_value_expression(fieldname, v); | ||
return util.format("%s",fieldvalue.toString()); | ||
case 'map': | ||
var retvalmap = "{"; | ||
for(key in fieldvalue) { | ||
retvalmap += "'"+key+"':'"+fieldvalue[key]+"'," | ||
} | ||
retvalmap = retvalmap.slice(0,retvalmap.length-1)+"}"; | ||
return retvalmap; | ||
case 'list': | ||
var retvallist = "["; | ||
for(key in fieldvalue) { | ||
retvallist += "'"+fieldvalue[key]+"'," | ||
} | ||
retvallist = retvallist.slice(0,retvallist.length-1)+"]"; | ||
return retvallist; | ||
case 'set': | ||
var retvalset = "{"; | ||
for(key in fieldvalue) { | ||
retvalset += "'"+fieldvalue[key]+"'," | ||
} | ||
retvalset = retvalset.slice(0,retvalset.length-1)+"}"; | ||
return retvalset; | ||
default: | ||
@@ -791,3 +812,3 @@ return fieldvalue; | ||
this._execute_table_query(query, null, function(err,results){ | ||
if(err) return callback(build_error('model.delete.dberror',err)); | ||
if(err) return callback(build_error('model.update.dberror',err)); | ||
callback(null, results); | ||
@@ -996,9 +1017,6 @@ }); | ||
this.constructor._execute_table_query(query, null, function(err, result){ | ||
if(err) return callback(err); | ||
this._update_self(function(err){ | ||
if(err) | ||
console.warn(err); | ||
callback(null, result); | ||
}); | ||
}.bind(this)); | ||
if(err) | ||
return callback(err); | ||
callback(null, result); | ||
}); | ||
}; | ||
@@ -1005,0 +1023,0 @@ |
@@ -81,5 +81,5 @@ var check = require('check-types'), | ||
"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"} | ||
"map" : {validator : validators.is_object, dbvalidator : "org.apache.cassandra.db.marshal.MapType"}, | ||
"list" : {validator : validators.is_array, dbvalidator : "org.apache.cassandra.db.marshal.ListType"}, | ||
"set" : {validator : validators.is_array, dbvalidator : "org.apache.cassandra.db.marshal.SetType"} | ||
}; | ||
@@ -86,0 +86,0 @@ |
{ | ||
"name": "express-cassandra", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"dependencies": { | ||
@@ -10,3 +10,7 @@ "async": "^1.0.0", | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"vows": "*", | ||
"mocha": "*", | ||
"chai": "*" | ||
}, | ||
"optionalDependencies": {}, | ||
@@ -17,2 +21,5 @@ "author": { | ||
}, | ||
"scripts": { | ||
"test": "node_modules/.bin/mocha" | ||
}, | ||
"license": "LGPL-3.0", | ||
@@ -19,0 +26,0 @@ "description": "Framework for cassandra object models in express", |
@@ -175,5 +175,13 @@ express-cassandra | ||
info: { | ||
mymap: { | ||
type: "map", | ||
typeDef: "<varchar, text>" | ||
}, | ||
mylist: { | ||
type: "list", | ||
typeDef: "<varchar>" | ||
}, | ||
myset: { | ||
type: "set", | ||
typeDef: "<varchar>" | ||
} | ||
@@ -187,3 +195,3 @@ | ||
When saving or updating composite types, use the string representation of the value like the following: | ||
When saving or updating composite types, use an object for a `map` value and use an array for `set` or `list` value like the following: | ||
@@ -194,3 +202,5 @@ ``` | ||
info: "{'key1':'val1','key2': 'val2'}" | ||
mymap: {'key1':'val1','key2': 'val2'}, | ||
mylist: ['value1', 'value2'], | ||
myset: ['value1', 'value2'] | ||
@@ -205,16 +215,3 @@ }); | ||
You may also use composite expressions supported by cassandra like the following: | ||
``` | ||
models.instance.Dictionary.update({},{ | ||
info: "info + {'hello':'world'}" | ||
},{},function(err){}); | ||
``` | ||
## Virtual fields | ||
@@ -221,0 +218,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89491
13
1686
3
518