There seems to be an issue with the SimpleSchema: The modifier is appearing empty after removing keys that are not in the schema

I implemented a new SimpleSchema for my collection. Below is the definition and schema of the collection:

GIST

Upon calling this method from the client side:

export const setEventInvitationStatus = new ValidatedMethod({
 name: 'events.updateParticipantStatus',

 mixins: [LoggedInMixin],

 checkLoggedInError: {
  error: 'notLogged',
 },

 validate: new SimpleSchema({
  eventId: { type: String },
  inviteTo: { type: String },
  newStatus: { type: String },
 }).validator(),

 run({ eventId, inviteTo, newStatus }) {
  Events.update(
    {  '_id': eventId, 'participants.userId': inviteTo },
   {
    $set: { 'participants.$.inviteStatus': newStatus },
   });
 },
});

However, I encountered an error:

Exception while invoking method 'events.updateParticipantStatus' { stack: 'Error: After filtering out keys not in the schema, your modifier is now empty\n    at [object Object].doValidate (packages/aldeed_collection2-core/lib/collection2.js:374:1)\n    at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/aldeed_collection2-core/lib/collection2.js:173:1)\n    at [object Object].run (imports/api/events/server/methods.js:101:10)\n    at [object Object].LoggedInMixin.methodOptions.run (packages/tunifight:loggedin-mixin/loggedin-mixin.js:28:16)\n    at ValidatedMethod._execute (packages/mdg:validated-method/validated-method.js:93:12)\n    at [object Object].ValidatedMethod.connection.methods._connection$methods.(anonymous function) (packages/mdg:validated-method/validated-method.js:54:23)\n    at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)\n    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)\n    at packages/ddp-server/livedata_server.js:711:19\n    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)',

What did I do wrong?

Answer №1

Ensure that your list of attendees is integrated into the structure:

validate: new SimpleSchema({
  eventID: { type: String },
  invitedTo: { type: String },
  statusUpdate: { type: String },
  attendeesList: { type: [Object]}, // array containing objects
 }).validator()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Remove Angular.js entirely from your system

Is it okay to remove all Angular files and directories without causing any issues? I've searched for information on uninstalling Angular but have come up empty-handed. ...

Ways to simplify a complex nested JSON structure by combining object values

I am working with a deeply nested json object that looks like the following: [ { "categoryId": "1", "subcategories": [ { "categoryId": "2", "subcategories": [ ...

Creating filters with Angular ES5 is a powerful tool for manipulating data in

Struggling with creating a pipe filter in Angular v 4.4.4 using ES5 for table results populated by *ngFor. Despite extensive research, no examples can be found. Is this even possible? If so, could someone please provide an example? This is the code snippe ...

Iterate through the values of an object and verify their presence in another object

I am working on a function where I need to check if any of the role names, passed in as a string with or without pipe separation, exist within an existing JavaScript array. While .includes works well for single names, it doesn't work perfectly when d ...

Secure login system featuring self-contained HTML and Javascript functionalities

I want to create an idle game that will save data on the server instead of using cookies. I am looking for a straightforward method (ideally without using MySQL or PHP) to implement user registration and login functionality using HTML5 and/or Javascript. ...

Choose particular content enclosed by two strings (across multiple lines)

Looking to use regex to extract specific text between two strings. For example: foo I have four toys bar //single line foo //multiline I have four toys bar foo I have three pets bar foo I have three pets bar How can I extract the text between & ...

Looping through a record retrieved from the database

I'm currently working on a project using Angular and Firebase. I have retrieved an object from Firebase and I am looking to render it in HTML. However, I am unsure how to access values from the object within the array. How can I loop through the auto- ...

Endless Loop Encountered When Attempting to Split a Vuex Array

If you want to check out my codesandbox setup, you can find it here. In this setup, three dates should be printed. The important parts of the code are as follows: import Vue from "vue"; import App from "./App"; import Vuex from "vuex"; Vue.use(Vuex); co ...

Modify the characteristic of a personalized directive

I have created a unique directive that allows me to load pages within a specified div element. .directive('page', function () { return { templateUrl: function (elem, attr) { return 'pages/page-' + attr.num + &ap ...

Tips for iterating within a Vue.js template without disrupting the HTML structure

Currently, I am attempting to implement a loop within a table. However, I have encountered an issue with the following code: <tr v-for="( block , index ) in listRenderBlock" :key="index"> <div v-for="( section , i ) in ...

Mongodb's $in operator is causing collscan instead of an index scan on the indexed field

My journey with Mongodb has just begun, and I am currently employing Mongodb version - 5.0.9 In my database, there is a collection called User User - { "_id" : "abcd", "name" : "Name" } The Index is as fol ...

An improved solution for avoiding repetitive typeof checks when accessing nested properties in the DOM

One common issue I encounter when working with nested DOM objects is the risk of undefined errors. To address this, I often use a conditional check like the one shown below: if("undefined" != typeof parent && "undefined" != typeof parent.main ...

Develop a NodeJS query for Mongodb that allows for case-insensitive searching within an array of data

I am currently working on a node.js script to query a MongoDB database using an array of data, specifically emails. The emails are stored as a single string, not an array, and I need the query to be case-insensitive. Below is my current query, but I am ope ...

Sharing JSON data between PHP and JavaScript/AJAX

In order to validate strings on my website, I am developing a validation mechanism using both Javascript and ajax for client-side validation and PHP for server-side validation. It is essential for both PHP and Javascript to utilize the same variables, suc ...

Understanding the process of querying a dynamic key in MongoDB's schema design

Presented below is the structure of a document: { _id : 1, key1 : { samekeyA : "value1", samekeyB : "value2" }, key2 : { samekeyA : "value3", sam ...

Receiving a 200 ok status, but encountering a response error in Postman

Receiving a response with a 200 OK status, but encountering an error message in Postman. { "errors": "Unable to log you in, please try again.", "success": false } Post Url: [{"key":"Content-Type","value":"application/json","descript ...

Find a solution to the issue of displaying react icons within JavaScript with embedded objects

When icons are added inside the JavaScript condition, the icon only appears as an object and does not display properly {!signUp ? `${(<FcGoogle />)}` + "Sign in With Google": `${(<FcGoogle />)} Sign Up With Google`} view image descri ...

What is the best way to overlay a 2D text layer on top of a Three.js scene?

I have successfully created a basic 3D scene using JavaScript. The scene features a THREE.SphereGeometry paired with a THREE.MeshNormalMaterial. However, I am now faced with the challenge of adding a text layer on top of the Three.js scene. Query: What is ...

Insert fresh user information into the div

Learning JavaScript is a challenge I'm tackling. I have a question that may seem trivial, but any assistance would be greatly appreciated. I currently have this code: Javascript <script type="text/javascript"> function fn(){ var Name = ...

What is the method to obtain the selector string for an HTML node element?

Essentially, my goal is to extract the selector string from an HTML element. Specifically, I want to start with the HTML element and retrieve its selector string (for example: button#myButton) function onclicked(e){ console.log(e.target); // This returns ...