Skip to content

Conversation

@lafeuil
Copy link

@lafeuil lafeuil commented Jun 12, 2020

Summary

When specified an array filter for an update query, only the first field of the filter object is cast.

With this merge request, all fields of the filter are iterated and cast.
Examples

    const schema = new Schema({
      comments: [{
        text: String,
        replies: [{ 
          beginAt: Date, 
          endAt: Date
        }]
      }]
    });
    const q = new Query();
    q.schema = schema;

    q.updateOne({}, { $set: { 'comments.$[x].replies.$[y].endAt': '2019-01-01' } }, {
      arrayFilters: [{ 'x.text': 123 }, { 'y.beginAt': { $gte: '2018-01-01' }, 'y.endAt': { $lt: '2020-01-01' } }]
    });

The endAt field in array filter is not cast to Date.

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants