Your module works great as long as you define your names in the base of the schema like this:
{first_name: String, last_name:String}
The second you want your schema to be like this:
{name : {first : String, last:String}}
You run into problems.
I wrote a function that fixes this. Either include it or add me to the repo and I'll make the changes.
var getProperty = function(key, doc) { var item = doc; var keys = key.split('.'); var iterations = keys.length - 1; for (var i = 0; i < iterations; i++) { item = item[keys.shift()]; }; return item[keys[0]];// Returns a 'pointer' to the correct property. }
Your module works great as long as you define your names in the base of the schema like this:
{first_name: String, last_name:String}
The second you want your schema to be like this:
{name : {first : String, last:String}}
You run into problems.
I wrote a function that fixes this. Either include it or add me to the repo and I'll make the changes.
var getProperty = function(key, doc) { var item = doc; var keys = key.split('.'); var iterations = keys.length - 1; for (var i = 0; i < iterations; i++) { item = item[keys.shift()]; }; return item[keys[0]];// Returns a 'pointer' to the correct property. }