mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			18 lines
		
	
	
		
			606 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			606 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const Database = require("better-sqlite3");
 | |
| let dbConnection;
 | |
| 
 | |
| const openDatabase = (documentPath) => { dbConnection = new Database(documentPath, { readonly: true }) };
 | |
| 
 | |
| const getRow = (query, params = []) => dbConnection.prepare(query).get(params);
 | |
| const getRows = (query, params = []) => dbConnection.prepare(query).all(params);
 | |
| const getValue = (query, params = []) => dbConnection.prepare(query).pluck().get(params);
 | |
| const getColumn = (query, params = []) => dbConnection.prepare(query).pluck().all(params);
 | |
| 
 | |
| module.exports = {
 | |
|     openDatabase,
 | |
|     getRow,
 | |
|     getRows,
 | |
|     getValue,
 | |
|     getColumn
 | |
| };
 |