I am trying to remove a checkin document by playersId and between a date range and keep getting the following error:
“Exception while simulating the effect of invoking ‘deleteCheckin’ Error: Can’t set timers inside simulations(…) Error: Can’t set timers inside simulations”
here is my code. Any idea why i’m getting that error? Thanks in advance.
on client.
//asign var to id feild of the player
var playerId = this._id;
//attach the id to the session
Session.set('selectedPlayer', playerId);
//assign var to get the session/id
var selectedPlayer = Session.get('selectedPlayer');
//pass delete call to server side meteor method for security
Meteor.call('deleteCheckin', selectedPlayer)
On the server
//in lib directory
Meteor.methods({
'deleteCheckin': function(selectedPlayer){
//start of day
// var startOfDay = moment().startOf('day');
var startOfDay = new Date();
startOfDay.setHours(0,0,0,0);
//end of day
var endOfDay = new Date();
endOfDay.setHours(23,59,59,999);
checkins.remove( {playersId: selectedPlayer},{ createdAt: { $gt: startOfDay, $lt: endOfDay} } )
},
});//end meteor methods`
since it said simulation error, I guess you can try to put the method in the server side only to see whether it has an error, I think that can help to debug the issue.
@shock that was the tip I needed. Thank you for helping me out. I only spent 5 1/2 hour trying to figure this out. You were right. It was interpreting my createdAt as the the 2nd argument instead of the first. It’s always the little things that i get hung up on.
I fixed the query and i have it working now. I replaced my query with the following if it helps anyone in the future.