@@ -701,12 +701,16 @@ DatabaseCollection.prototype.update = function (query, update, options) {
701
701
}
702
702
703
703
for ( attributeName in update ) {
704
- if ( typeof docs [ i ] [ attributeName ] !== 'undefined' ) {
704
+ if ( typeof docs [ i ] [ attributeName . split ( '.' ) [ 0 ] ] !== 'undefined' ) {
705
705
if ( this . name !== '_Schema' && this . name !== '_Model' && this . name !== '_GeneratedModel' ) {
706
706
// check type
707
707
type = '' ;
708
708
if ( attributeName . indexOf ( '_' ) !== 0 ) {
709
- type = schema [ attributeName ] . type ;
709
+ if ( attributeName . indexOf ( '.' ) !== - 1 ) {
710
+ type = $metamodel . getModelPathType ( this . name , attributeName ) ;
711
+ } else {
712
+ type = schema [ attributeName ] . type ;
713
+ }
710
714
} else {
711
715
if ( $metamodel . getMetaDef ( ) [ attributeName ] ) {
712
716
type = $metamodel . getMetaDef ( ) [ attributeName ] . type ;
@@ -727,13 +731,21 @@ DatabaseCollection.prototype.update = function (query, update, options) {
727
731
'value' : update [ attributeName ]
728
732
} ) ;
729
733
}
730
- $workflow . state ( {
731
- 'component' : docs [ i ] . _id ,
732
- 'state' : attributeName ,
733
- 'data' : [ update [ attributeName ] ]
734
- } ) ;
734
+ if ( type === 'array' ) {
735
+ $workflow . state ( {
736
+ 'component' : docs [ i ] . _id ,
737
+ 'state' : attributeName ,
738
+ 'data' : [ update [ attributeName ] , 'reset' ]
739
+ } ) ;
740
+ } else {
741
+ $workflow . state ( {
742
+ 'component' : docs [ i ] . _id ,
743
+ 'state' : attributeName ,
744
+ 'data' : [ update [ attributeName ] ]
745
+ } ) ;
746
+ }
735
747
} else {
736
- $log . invalidPropertyTypeOnDbUpdate ( this . name , docs [ i ] . _id , attributeName , update [ attributeName ] , schema [ attributeName ] . type ) ;
748
+ $log . invalidPropertyTypeOnDbUpdate ( this . name , docs [ i ] . _id , attributeName , update [ attributeName ] , type ) ;
737
749
}
738
750
} else {
739
751
$log . unknownPropertyOnDbUpdate ( this . name , attributeName , docs [ i ] . _id ) ;
0 commit comments