These are chat archives for Automattic/mongoose

8th
Jan 2017
Zakiir Juman
@zakiirjuman
Jan 08 2017 00:20

hi everyone, I've got a document a that looks like:

{ field_1: 0, field_2: 0}

If I change a variable like this:

a.field_1 = 1;
a.save();
and before the save finishes, I also do:
a.field_2 = 1;
a.save();
do I run the risk of some kind of race condition?
or will my returned document still come out as expected:
{field_1: 1, field_2: 1}
Zakiir Juman
@zakiirjuman
Jan 08 2017 00:29
I've tried it locally and it always seems to work, but I just wanted to make sure that whatever is inputted locally actually takes precedence to any returned document fields.