express-cassandra
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var util = require('util'); | ||
@@ -22,2 +23,5 @@ | ||
}, | ||
'model.tablecreation.dbalter': { | ||
msg: 'Error during altering of DB Table -> %s' | ||
}, | ||
'model.tablecreation.dbindex': { | ||
@@ -24,0 +28,0 @@ msg: 'Error during creation of index on DB Table -> %s' |
@@ -0,3 +1,4 @@ | ||
"use strict"; | ||
var TYPE_MAP = require('./cassandra_types'); | ||
var _ = require('lodash'); | ||
var lodash = require('lodash'); | ||
@@ -7,3 +8,3 @@ var schemer = { | ||
normalize_model_schema: function(model_schema){ | ||
var output_schema = _.clone(model_schema,true); | ||
var output_schema = lodash.cloneDeep(model_schema,true); | ||
var good_fields = {fields : true, key:true, clustering_order:true, materialized_views:true, indexes:true, custom_index: true, custom_indexes: true}; | ||
@@ -118,2 +119,5 @@ | ||
} | ||
else { | ||
output_schema.materialized_views = {}; | ||
} | ||
@@ -134,2 +138,5 @@ if(output_schema.indexes) { | ||
} | ||
else { | ||
output_schema.indexes = []; | ||
} | ||
@@ -157,2 +164,5 @@ if(output_schema.custom_index) { | ||
} | ||
else { | ||
output_schema.custom_indexes = []; | ||
} | ||
@@ -159,0 +169,0 @@ return output_schema; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var cql = require("cassandra-driver"), | ||
@@ -60,3 +61,3 @@ types = cql.types, | ||
_get_system_client : function(){ | ||
var connection = lodash.clone(this._connection); | ||
var connection = lodash.cloneDeep(this._connection); | ||
delete connection.keyspace; | ||
@@ -356,9 +357,9 @@ | ||
if(!options.udas[uda_key].input_types) { | ||
throw("No input_types defined for user defined function: "+udf_key); | ||
throw("No input_types defined for user defined function: "+uda_key); | ||
} | ||
if(!(options.udas[uda_key].input_types instanceof Array)) { | ||
throw("input_types must be an array for user defined function: "+udf_key); | ||
throw("input_types must be an array for user defined function: "+uda_key); | ||
} | ||
if(options.udas[uda_key].input_types.length < 1) { | ||
throw("input_types array cannot be blank for user defined function: "+udf_key); | ||
throw("input_types array cannot be blank for user defined function: "+uda_key); | ||
} | ||
@@ -467,3 +468,3 @@ if(!options.udas[uda_key].sfunc) { | ||
_set_client : function(client){ | ||
var define_connection_options = lodash.clone(this._connection); | ||
var define_connection_options = lodash.cloneDeep(this._connection); | ||
@@ -533,3 +534,4 @@ this._client = client; | ||
connect: this.connect.bind(this), | ||
dropTableOnSchemaChange: this._options.dropTableOnSchemaChange | ||
dropTableOnSchemaChange: this._options.dropTableOnSchemaChange, | ||
migration: this._options.migration | ||
}; | ||
@@ -536,0 +538,0 @@ |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var check = require('check-types'), | ||
@@ -2,0 +3,0 @@ util = require('util'), |
{ | ||
"name": "express-cassandra", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"dependencies": { | ||
@@ -9,3 +9,6 @@ "async": "^1.0.0", | ||
"debug": "^2.2.0", | ||
"lodash": "^3.9.3" | ||
"deep-diff": "^0.3.4", | ||
"lodash": "^4.14.2", | ||
"object-hash": "1.1.4", | ||
"readline-sync": "^1.4.4" | ||
}, | ||
@@ -12,0 +15,0 @@ "devDependencies": { |
@@ -49,10 +49,31 @@ [![Build Status](https://travis-ci.org/masumsoft/express-cassandra.svg)](https://travis-ci.org/masumsoft/express-cassandra) | ||
}, | ||
//If dropTableOnSchemaChange=true, then if your model schema changes, | ||
//the corresponding cassandra table will be dropped and recreated with | ||
//the new schema. Setting this to false will send an error message | ||
//in callback instead for any model attribute changes. | ||
//recommended to keep it false in production, use true for development convenience. | ||
dropTableOnSchemaChange: false, | ||
//If createKeyspace=false, then it won't be checked whether the | ||
//specified keyspace exists and, if not, it won't get created automatically. | ||
/******************************************************************** | ||
Automatic migration is supported. When your model schema changes, the | ||
config variable `migration` defines the migration behaviour. | ||
********************************************************************* | ||
`alter`, will try to alter the corresponding cassandra table to match | ||
the new schema. This operation will try to keep the existing data in | ||
the table and put null data in the newly created fields. Note that if | ||
a field in removed in the changed schema then the column will be | ||
dropped from the table and the data associated with the column or | ||
field will be lost. Also for primary key or clustering_order changes, | ||
the table must be dropped and data will be lost in the process because | ||
cassandra won't allow altering primary key. The module will ask for a | ||
confirmation from the user in the terminal whether to perform the | ||
required alter/drop operations per changed table. | ||
********************************************************************* | ||
`drop`, will always drop and recreate the table and indexes in case | ||
of schema change. This will wipe out all data in that table. It will | ||
ask for a confirmation from the user in the terminal whether to perform | ||
the required drop operations per changed table. | ||
********************************************************************* | ||
`safe` will send an error message in callback for any kind of model | ||
attribute changes. You need to migrate yourself. This is the recommended | ||
setting for production. Note that if NODE_ENV==="production" then | ||
regardless of the migration setting, `safe` is always used to protect | ||
inadvertent deletion of your data. | ||
*********************************************************************/ | ||
migration: 'safe', | ||
//If createKeyspace=false, then it won't be checked whether the specified | ||
//keyspace exists and, if not, it won't get created automatically. | ||
createKeyspace: true | ||
@@ -106,10 +127,31 @@ } | ||
}, | ||
//If dropTableOnSchemaChange=true, then if your model schema changes, | ||
//the corresponding cassandra table will be dropped and recreated with | ||
//the new schema. Setting this to false will send an error message | ||
//in callback instead for any model attribute changes. | ||
//recommended to keep it false in production, use true for development convenience. | ||
dropTableOnSchemaChange: false, | ||
//If createKeyspace=false, then it won't be checked whether the | ||
//specified keyspace exists and, if not, it won't get created automatically. | ||
/******************************************************************** | ||
Automatic migration is supported. When your model schema changes, the | ||
config variable `migration` defines the migration behaviour. | ||
********************************************************************* | ||
`alter`, will try to alter the corresponding cassandra table to match | ||
the new schema. This operation will try to keep the existing data in | ||
the table and put null data in the newly created fields. Note that if | ||
a field in removed in the changed schema then the column will be | ||
dropped from the table and the data associated with the column or | ||
field will be lost. Also for primary key or clustering_order changes, | ||
the table must be dropped and data will be lost in the process because | ||
cassandra won't allow altering primary key. The module will ask for a | ||
confirmation from the user in the terminal whether to perform the | ||
required alter/drop operations per changed table. | ||
********************************************************************* | ||
`drop`, will always drop and recreate the table and indexes in case | ||
of schema change. This will wipe out all data in that table. It will | ||
ask for a confirmation from the user in the terminal whether to perform | ||
the required drop operations per changed table. | ||
********************************************************************* | ||
`safe` will send an error message in callback for any kind of model | ||
attribute changes. You need to migrate yourself. This is the recommended | ||
setting for production. Note that if NODE_ENV==="production" then | ||
regardless of the migration setting, `safe` is always used to protect | ||
inadvertent deletion of your data. | ||
*********************************************************************/ | ||
migration: 'safe', | ||
//If createKeyspace=false, then it won't be checked whether the specified | ||
//keyspace exists and, if not, it won't get created automatically. | ||
createKeyspace: true | ||
@@ -138,2 +180,5 @@ } | ||
### Important Note on Migrations Support | ||
Current support for migration is an experimental feature and should be set to `safe` for production environments. When set to `alter` or `drop` the ORM will try to take a conservative approach and will ask the user for confirmation when doing any data destructive operation. But as this feature is new and not yet stable, you might encounter some bugs or glitches here and there. Please report an issue in [github](https://github.com/masumsoft/express-cassandra/issues/) if you face any. The team will try their best to fix the problem within short time. | ||
### Connecting to cassandra using authentication | ||
@@ -140,0 +185,0 @@ |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
module.exports = { | ||
@@ -2,0 +3,0 @@ "fields": { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
module.exports = { | ||
@@ -2,0 +3,0 @@ fields: { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
module.exports = { | ||
@@ -2,0 +3,0 @@ "fields": { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
module.exports = { | ||
@@ -2,0 +3,0 @@ "fields": { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var models = require('../index'); | ||
@@ -26,3 +27,3 @@ var chai = require('chai'); | ||
}, | ||
dropTableOnSchemaChange: true, | ||
migration: 'drop', | ||
createKeyspace: true, | ||
@@ -29,0 +30,0 @@ udts: { |
Sorry, the diff of this file is too big to display
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
248550
4008
1367
8
3
+ Addeddeep-diff@^0.3.4
+ Addedobject-hash@1.1.4
+ Addedreadline-sync@^1.4.4
+ Addeddeep-diff@0.3.8(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedobject-hash@1.1.4(transitive)
+ Addedreadline-sync@1.4.10(transitive)
- Removedlodash@3.10.1(transitive)
Updatedlodash@^4.14.2