Adds the $position modifier to $push in minimongo. Also adds tests.
Behavior of $push with multiple modifiers is documented here as
Update array to add elements in the correct position.
Apply sort, if specified.
Slice the array, if specified.
Store the array.
As described in the last paragraph here, if value of $position exceeds the size of the array to be modified, then the operation is the same as not using the $position at all.
The minimongo code I added still runs through the $position code path in that case. To short-circuit, you could add if (position < target[index].length) position = arg.$positionhere, which would result in running through the regular code path. I am not sure which behavior is desired, but it should not matter anyways.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.