I am getting the following error with my cloud functions, honestly i dont understand what it means but im pretty sure its not a problem with my cloud functions. im guessing its some duplicate back end code causing an error maybe? my server url is https://nrgav5mkt344.moralis.io:2053/server
Error: Before save opts already set for Bookings
at Object.Moralis.Cloud.beforeSave (/moralis-server/lib/cloud-code/plugins/index.js:31:33)
at eval (eval at customUserPlugin (/moralis-server/cloud/main.js:6:21), :1:6291)
at customUserPlugin (/moralis-server/cloud/main.js:6:21)
at /moralis-server/lib/cloud-code/plugins/index.js:62:15
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.initialize (/moralis-server/lib/cloud-code/plugins/index.js:51:3)
below is my cloud functions code that causes the error, if i remove this code the error goes away.
to clarify this is the ONLY beforeSave function in all my cloud functions that deals with βBookingsβ class.
any help is appreciated thanks!
Moralis.Cloud.beforeSave("Bookings", async (request) => {
const user = request.user;
// const object = request.object;
const query = new Moralis.Query('Bookings');
query.equalTo("user", user);
query.containedIn("completed", false);
const count = await query.count();
if (count >= 10) {
throw new Error(`You have reached your limit of 10 ongoing services booked per user. Please finalise an existing ongoing service before making a new booking.`);
};
},
{
fields: {
bookingDescription: {
type: String,
options: val => val.length <= 500,
error: "Description is too long, please keep it less than 500 characters (including spaces).",
},
},
requireUser: true,
}
);