Skip to content

'Failed validation: The positional operator did not find the match needed from the query' when using updateAsync() #471

Description

@KAlanBeck

Describe the bug

I've come across the error 'Failed validation The positional operator did not find the match needed from the query.' in a few different places in our codebase when trying to use updateAsync to set an object in the DB. I'm not sure if this is something I am doing wrong or if it's an actual issue but any help is appreciated.

The schema:

const orderSchema = new SimpleSchema({
appointment: {
    type: Object,
    label: 'Appointment',
    optional: true,
    security: {
      public: false,
    }
  },
  'appointment.dateTime': {
    type: Date,
    label: 'Date and time of appointment',
    optional: true,
    security: {
      public: false,
    }
  },
  'appointment.date': {
    type: String,
    label: 'Date of appointment',
    optional: true,
    security: {
      public: false,
    }
  },
  'appointment.time': {
    type: String,
    label: 'Time of appointment',
    optional: true,
    security: {
      public: false,
    }
  },
  'appointment.type': {
    type: String,
    label: 'Type of appointment',
    allowedValues: ['appointment', 'walkin'],
    optional: true,
    security: {
      public: false,
    }
  },
  'appointment.notes': {
    type: String,
    label: 'Walk-in notes',
    optional: true,
    security: {
      public: false,
    }
  },
});

The updateAsync:

const appointmentData = {};

    if (appointment.type === 'appointment') {
      appointmentData.appointment = {
        dateTime: appointment.dateTime,
        date: appointment.date,
        time: appointment.time,
        type: appointment.type,
      };
    } else {
      appointmentData.appointment = {
        type: appointment.type,
        notes: appointment.notes
      };
    }

await Orders.updateAsync({
      _id: orderId
    }, {
      $set: appointmentData
    });

Expected behavior
I've tried a few different syntax changes and ways of structuring the object but nothing seems to help.

The current workaround I have is to change the updateAsync to rawCollection().updateOne() but you lose out on the instant reactivity from Meteor when you using that so I'd like to find a solution to why our updateAsync's are failing.

Versions (please complete the following information):

  • Meteor version: 3.2.2
  • Browser: chrome
  • Version: 4.1.4

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions