Merge pull request #567 from IlyaDiallo/master

Accept subdocuments keys ("object.subobject"), to allow atomic updates of an object field.
This commit is contained in:
Fosco Marotto
2016-02-26 02:05:03 -08:00
3 changed files with 50 additions and 1 deletions

View File

@@ -426,6 +426,12 @@ Schema.prototype.validateField = function(className, key, type, freeze) {
// Just to check that the key is valid
transform.transformKey(this, className, key);
if( key.indexOf(".") > 0 ) {
// subdocument key (x.y) => ok if x is of type 'object'
key = key.split(".")[ 0 ];
type = 'object';
}
var expected = this.data[className][key];
if (expected) {
expected = (expected === 'map' ? 'object' : expected);