mirror of
https://github.com/stfrigerio/sqliteDB.git
synced 2026-07-22 05:38:02 +00:00
implemented requested changes
This commit is contained in:
parent
ff7551e1ca
commit
5d9cd14a7b
2 changed files with 9 additions and 8 deletions
6
main.ts
6
main.ts
|
|
@ -40,7 +40,7 @@ export default class SqliteDBPlugin extends Plugin {
|
|||
|
||||
this.addCommand({
|
||||
id: "dump-table-to-notes",
|
||||
name: "Dump Table to Notes",
|
||||
name: "Dump table to notes",
|
||||
callback: async () => {
|
||||
await this.openDatabase(); // ensure DB is loaded
|
||||
|
||||
|
|
@ -107,10 +107,8 @@ class SqliteDBSettingTab extends PluginSettingTab {
|
|||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl("h2", { text: "SQLite DB Plugin Settings" });
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Database File Path")
|
||||
.setName("Database file path")
|
||||
.setDesc("Absolute path to the .db file on disk.")
|
||||
.addText((text) =>
|
||||
text
|
||||
|
|
|
|||
|
|
@ -62,12 +62,13 @@ export async function convertEntriesInNotes(dbService: DBService, tableName: str
|
|||
|
||||
// Check if folder already exists; if not, create it
|
||||
let folder = app.vault.getAbstractFileByPath(targetFolderPath);
|
||||
if (!folder) {
|
||||
folder = await app.vault.createFolder(targetFolderPath);
|
||||
} else if (!(folder instanceof TFolder)) {
|
||||
if (folder && !(folder instanceof TFolder)) {
|
||||
new Notice(`A file named "${folderName}" already exists and is not a folder.`);
|
||||
return;
|
||||
}
|
||||
if (!folder) {
|
||||
folder = await app.vault.createFolder(targetFolderPath);
|
||||
}
|
||||
|
||||
// 4) Query *all* rows from the table
|
||||
const allRowsResult = db.exec(`SELECT * FROM "${tableName}";`);
|
||||
|
|
@ -98,9 +99,11 @@ export async function convertEntriesInNotes(dbService: DBService, tableName: str
|
|||
|
||||
// If file already exists, append a suffix
|
||||
let suffix = 1;
|
||||
while (app.vault.getAbstractFileByPath(notePath)) {
|
||||
let existingFile = app.vault.getAbstractFileByPath(notePath);
|
||||
while (existingFile && existingFile instanceof TFile) {
|
||||
suffix++;
|
||||
notePath = `${targetFolderPath}/${safeFileName}_${suffix}.md`;
|
||||
existingFile = app.vault.getAbstractFileByPath(notePath);
|
||||
}
|
||||
|
||||
// Build frontmatter with all columns
|
||||
|
|
|
|||
Loading…
Reference in a new issue