You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My application defines two different dynamodb connections in config/connections.js for two separate environments. The connections use the same AWS credentials but different regions. The connection is set depending on the NODE_ENV variable, using the standard config/env/env_name.js files.
Here is an example of the relevant code in connections.js:
Let's use my local environment as an example. If, in config/env/local.js I export:
models: {
connection: 'liveDynamo'
}
I get the following error trace:
/Users/Traverse/api/node_modules/sails-dynamodb/index.js:851
adapter._valueEncode(collection.definition, values);
^
TypeError: Cannot read property 'definition' of undefined
at Object.module.exports.adapter.create (/Users/Traverse/api/node_modules/sails-dynamodb/index.js:851:38)
at module.exports.create (/Users/Traverse/api/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:84:13)
at bound.createValues (/Users/Traverse/api/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:214:16)
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:74:20
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:708:13
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:263:32
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:705:17
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:263:32
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
at bound.module.exports.beforeCreate (/Users/Traverse/api/api/models/Latency.js:67:12)
at fn (/Users/Traverse/api/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:41:10)
at /Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:162:20
at iterate (/Users/Traverse/api/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:256:13)
However, if I switch the order of the connections in the config/connections.js file, everything works fine. Using the devDynamo connection works as well. This seems to be because the latter connection always overwrites the _collectionRefrences variable on line 348 in sails-dynamodb/index.js.
For anyone else running into similar issues, I would recommend overriding the variables directly in config/env/env_name.js, like so:
My application defines two different dynamodb connections in
config/connections.js
for two separate environments. The connections use the same AWS credentials but different regions. The connection is set depending on theNODE_ENV
variable, using the standardconfig/env/env_name.js
files.Here is an example of the relevant code in connections.js:
}
Let's use my local environment as an example. If, in
config/env/local.js
I export:I get the following error trace:
However, if I switch the order of the connections in the
config/connections.js
file, everything works fine. Using thedevDynamo
connection works as well. This seems to be because the latter connection always overwrites the_collectionRefrences
variable on line 348 insails-dynamodb/index.js
.For anyone else running into similar issues, I would recommend overriding the variables directly in
config/env/env_name.js
, like so:The text was updated successfully, but these errors were encountered: