Timers Stops Working

hi, i wrote this code for a Timer to delete each object that has been on a table for more than 30 days but its not working
i tested this to delete an object that lasts for more than one day and it worked fine but now its not working i dont know why?

let queryBuilder = Backendless.DataQueryBuilder.create();
let monthe = Date.now() - 30*24*60*60*1000;
queryBuilder.setSortBy('created desc')
queryBuilder.setPageSize(100);
return Backendless.Data.of('PropertyModels').find(queryBuilder)
.then( data => {
	if( data.length > 0 ) {
		return Backendless.Data.of('PropertyModels').bulkDelete( `created >= monthe`) // delete obsolete
	}
})
.catch( function( error ) {
	console.log( "Server reported an error " + error )
})

please help, its really annoying

Hi @Mohammed_Abdalla,

you have a mistake in query for bulkDelete, it should look like following:
return Backendless.Data.of('PropertyModels').bulkDelete( `created >= ${monthe}`)

Regards,
Stanislaw

ok, i will try

@stanislaw.grin
Its not working

Please provide your app id

@stanislaw.grin
app id :
66080E8F-379E-C76A-FFBA-B08F90122D00

Please try this code in execute function:

let month = Date.now() - 30 * 24 * 60 * 60 * 1000

return Backendless.Data.of('DogCard').bulkDelete(`created <= ${ month }`) // delete obsolete
  .catch(function(error) {
    console.log('Server reported an error ' + error)
  })
1 Like

ok

works now

@stanislaw.grin
Can you till me what was the error exactly ?

Error in logic - you had created >= monthe while it should have been created <= ${monthe} (less than and month in js template string to evaluate value of variable).
Also I have remove redundant code (find is not required before bulk delete)

ok, anyway
I am not familiar with js