@owrede/vault-memory 2.0.0-rc.1 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +10 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1207,13 +1207,16 @@ function backfillSectionsFromChunks(db) {
|
|
|
1207
1207
|
"SELECT * FROM chunks WHERE note_id = ? ORDER BY id ASC"
|
|
1208
1208
|
);
|
|
1209
1209
|
const insertSection = db.prepare(`
|
|
1210
|
-
INSERT INTO sections
|
|
1210
|
+
INSERT OR IGNORE INTO sections
|
|
1211
1211
|
(note_id, anchor, heading_path, heading_text, level,
|
|
1212
1212
|
parent_id, ord, chunk_id_first, chunk_id_last, created_at)
|
|
1213
1213
|
VALUES
|
|
1214
1214
|
(@note_id, @anchor, @heading_path, @heading_text, @level,
|
|
1215
1215
|
@parent_id, @ord, @chunk_id_first, @chunk_id_last, @created_at)
|
|
1216
1216
|
`);
|
|
1217
|
+
const lookupExistingSection = db.prepare(
|
|
1218
|
+
"SELECT id FROM sections WHERE note_id = ? AND anchor = ?"
|
|
1219
|
+
);
|
|
1217
1220
|
let backfilled = 0;
|
|
1218
1221
|
const now = Date.now();
|
|
1219
1222
|
for (const note of notesRows) {
|
|
@@ -1249,7 +1252,12 @@ function backfillSectionsFromChunks(db) {
|
|
|
1249
1252
|
created_at: now
|
|
1250
1253
|
};
|
|
1251
1254
|
const info = insertSection.run(row);
|
|
1252
|
-
|
|
1255
|
+
if (info.changes > 0) {
|
|
1256
|
+
insertedIds.push(Number(info.lastInsertRowid));
|
|
1257
|
+
} else {
|
|
1258
|
+
const existing2 = lookupExistingSection.get(note.id, s.anchor);
|
|
1259
|
+
insertedIds.push(existing2 ? Number(existing2.id) : null);
|
|
1260
|
+
}
|
|
1253
1261
|
}
|
|
1254
1262
|
backfilled++;
|
|
1255
1263
|
}
|