My app allows the user to create some objects called "Meeting" with a date field and a boolean field. I need to create a job to delete these objects exactly 1 hour before that date if the boolean field is False. I thought a Background-job could be the solution but after i read the parse documentation i'm not so sure. After i created a background-job i can schedule the job to start at a precise time and to repeat itself every, for example, 1 minute. Considering having thousands of objects wouldn't be a better solution to just plan a specific delete task on the date i want? Is this possible with a background-job? The other solution i found is client-side, by checking the objects from the app itself and calling a deleteInBackground if needed but i would be happy to avoid this because i think a server-side solution would be more efficient.
Asked
Active
Viewed 192 times
0
-
What granularity does "exactly" mean in "exactly 1 hour before that date". Does it mean to the millisecond or could it mean "to the nearest five minutes"? That will affect the solution you need. – Rog Aug 26 '14 at 16:51
-
If the Meeting object date is tomorrow at noon it should be deleted tomorrow at 11:00. If it cannot be done like this i can of course accept a 5 minutes torelance.. – Diego Aug 26 '14 at 17:38
-
1Then set a job to run every 5 minutes and accept the near misses. Also, use Timothy's answer. – Rog Aug 27 '14 at 07:24
1 Answers
2
The more common solution is to solve this in your query logic, i.e. only query for those where the boolean is true.
You could use an OR type query:
- All records where "meetingDate" is <= (now + 1hr) AND "isConfirmed" == false
- All records where "meetingDate" is > (now + 1hr)
You can delete them at leisure as needed and the query will still work fine.
Then your background job is able to run (every 5 minutes is max frequency BTW, thus Roger's comment) and clean them up.

Timothy Walters
- 16,866
- 2
- 41
- 49