mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			752 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			752 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const repository = require('../../src/services/repository');
 | 
						|
 | 
						|
module.exports = () => {
 | 
						|
    for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'search' AND isProtected = 0 AND isDeleted = 0")) {
 | 
						|
        try {
 | 
						|
            let origContent = note.getJsonContent();
 | 
						|
 | 
						|
            if (!origContent) {
 | 
						|
                continue;
 | 
						|
            }
 | 
						|
 | 
						|
            note.addLabel('searchString', origContent.searchString);
 | 
						|
 | 
						|
            note.setContent('');
 | 
						|
 | 
						|
            note.mime = 'text/plain';
 | 
						|
            note.save();
 | 
						|
 | 
						|
            console.log(`Migrated search note ${note.noteId}`);
 | 
						|
        }
 | 
						|
        catch (e) {
 | 
						|
            console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);
 | 
						|
        }
 | 
						|
    }
 | 
						|
};
 |