I am creating an app to store schedules and I do not want two schedules with the same date. To combat this I added this code (javascript) to the onBeforeCreate()
and onBeforeSave()
events.
var query = app.models.DataSource.newQuery(); // New query
query.filters.date._equals = record.date; //Search for a record that has the same
if (query.run().length) {
throw new Error("There is already a schedule on that date"); // Throw an error
}
This works great to prevent the duplicate entries, but how would I go about detecting this on the client side and reporting it to the user?
Its probably a quick fix but any input would be greatly appreciated :)
Thanks!!