Skip to content

Commit

Permalink
update implied $set operator, fix $set value as string
Browse files Browse the repository at this point in the history
  • Loading branch information
globules-io committed Apr 6, 2024
1 parent 0924040 commit 2bfbc3a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions collection.mongogx.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,22 @@ OGX.MongogxCollection = class{
_update(__collection, __update){
let match = 0;
for(let _id in __collection){
let oper, ev, ev2, pre, pro;
for(let op in __update){
let oper, ev, ev2, pre, pro, val;
for(let op in __update){
if(typeof __update[op] !== 'object'){
__update = {$set:__update};
op = '$set';
}
if(op.substr(0,1) === '$'){
oper = op.substr(1);
oper = op.substr(1);
for(let prop in __update[op]){

//eval
switch(oper){
case 'set':
ev = eval('this.data[_id].'+prop+'='+__update[op][prop]);
val = __update[op][prop];
typeof val === 'string' ? val = '"'+val+'"' : null;
ev = eval('this.data[_id].'+prop+'='+val);
if(typeof(ev) !== 'undefined'){
match++;
}
Expand Down

0 comments on commit 2bfbc3a

Please sign in to comment.