Mongoose selects, fills and stores behavior differently on Mac and Windows

This is what i did

static populateReferralLinks(){
    return Promise.coroutine(function*(){
       let companies = yield Company.find({},'billing referral current_referral_program')
                                        .populate('billing.user','emails name');

       for(let i = 0 ; i < length ; i++){  
         companies[i].referral.is_created = true;
         companies[i].referral.referral_email = companies[i].billing.user.emails[0].email;
         companies[i] = yield companies[i].save();
       }
       return companies;
    }).apply(this)
        .catch((err) => {
            throw err;
        });
}

      

I have a funciton in which I only select 3 fields to go ahead with ie billing, current_referral_program and referral. And the filling user using the link stored in billing.user. Now when I call this function then on the line

<strong> companies [I] .save ();

The following command is displayed in terminal in windows

Mongoose: companies.update(
{ _id: ObjectId("58d12e1a588a96311075c45c") }, 
{ '$set': 
   { billing: 
      { configured: false, 
        user: ObjectId("58d12e16588a96311075c45a") }, 
     referral: 
     { is_created: true,  
       referral_email: 'jadon.devesh98@gmail.com', 
     }, 
     updatedAt: new Date("Wed, 22 Mar 2017 12:02:55 GMT") 
   } 
}
)

      

But in Mac terminal it shows this command

Mongoose: companies.update({ _id: ObjectId("58d12e1a588a96311075c45c") }) { '$set': { billing: { configured: false, user: ObjectId("58d12e16588a96311075c45a") }, current_limit: {}, current_usage: {},referral: { is_created: true, referral_email: 'jadon.devesh98@gmail.com'}}, '$unset': { updatedAt: 1 } }

      

Now, I didn't mention that current_limit and current_usage are empty. it works fine on Windows, but on Mac it sets current_limit and current_usage to empty, thus updating my document with empty objects on Mac, but not on windows.

It should behave the same on both OS, but it doesn't.

+3


source to share


1 answer


Apparently this issue was in Mongoose 4.5.8 and solved in the latest ie 4.9.1 Check here



+3


source







All Articles