constnotesForCleanup=awaitrepository.getEntities("SELECT * FROM notes WHERE isDeleted = 1 AND content != '' AND dateModified <= ?",[dateUtils.dateStr(cutoffDate)]);
// it's better to not use repository for this because it will complain about saving protected notes
// out of protected session
for(constnoteofnotesForCleanup){
note.content=null;
awaitnote.save();
}
awaitsql.execute("UPDATE notes SET content = NULL WHERE isDeleted = 1 AND content IS NOT NULL AND dateModified <= ?",[dateUtils.dateStr(cutoffDate)]);
constnotesRevisionsForCleanup=awaitrepository.getEntities("SELECT note_revisions.* FROM notes JOIN note_revisions USING(noteId) WHERE notes.isDeleted = 1 AND note_revisions.content != '' AND notes.dateModified <= ?",[dateUtils.dateStr(cutoffDate)]);
for(constnoteRevisionofnotesRevisionsForCleanup){
noteRevision.content=null;
awaitnoteRevision.save();
}
awaitsql.execute("UPDATE note_revisions SET content = NULL WHERE note_revisions.content IS NOT NULL AND noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1 AND notes.dateModified <= ?)",[dateUtils.dateStr(cutoffDate)]);