Is there any way to use dynamic keys with the node-mongodb-native driver? By this I mean having a variable hold the key instead of using the key directly.
As in when
You can write a small function that creates such an object
var obj = function(key, value, obj) {
obj = obj || {};
obj[key] = value;
return obj;
}
// Usage
foo = obj('foo' + 'bar', 'baz');
// -> {'foobar': 'baz'}
foo = obj('stack' + 'over', 'flow', foo);
// -> {'foobar': 'baz', 'stackover': 'flow'}
Don't know if calling this function obj is a good idea.