for(constnoteIdofsql.getColumn<string>(`SELECT noteId FROM note_contents`)){
constrow=sql.getRow<NoteContentsRow>(`SELECT noteId, content, dateModified, utcDateModified FROM note_contents WHERE noteId = ?`,[noteId]);
for(constnoteIdofsql.getColumn<string>(/*sql*/`SELECT noteId FROM note_contents`)){
constrow=sql.getRow<NoteContentsRow>(/*sql*/`SELECT noteId, content, dateModified, utcDateModified FROM note_contents WHERE noteId = ?`,[noteId]);
constblobId=utils.hashedBlobId(row.content);
if(!existingBlobIds.has(blobId)){
@ -40,8 +40,8 @@ export default () => {
sql.execute("UPDATE notes SET blobId = ? WHERE noteId = ?",[blobId,row.noteId]);
}
for(constnoteRevisionIdofsql.getColumn(`SELECT noteRevisionId FROM note_revision_contents`)){
constrow=sql.getRow<NoteRevisionContents>(`SELECT noteRevisionId, content, utcDateModified FROM note_revision_contents WHERE noteRevisionId = ?`,[noteRevisionId]);
for(constnoteRevisionIdofsql.getColumn(/*sql*/`SELECT noteRevisionId FROM note_revision_contents`)){
constrow=sql.getRow<NoteRevisionContents>(/*sql*/`SELECT noteRevisionId, content, utcDateModified FROM note_revision_contents WHERE noteRevisionId = ?`,[noteRevisionId]);
@ -70,7 +70,7 @@ function setNoteAttribute(req: Request) {
constnoteId=req.params.noteId;
constbody=req.body;
constattributeId=sql.getValue<string|null>(`SELECT attributeId FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = ? AND name = ?`,[noteId,body.type,body.name]);
constattributeId=sql.getValue<string|null>(/*sql*/`SELECT attributeId FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = ? AND name = ?`,[noteId,body.type,body.name]);
if(attributeId){
constattr=becca.getAttribute(attributeId);
@ -196,7 +196,7 @@ function createRelation(req: Request) {
consttargetNoteId=req.params.targetNoteId;
constname=req.params.name;
constattributeId=sql.getValue<string>(`SELECT attributeId FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`,[
constattributeId=sql.getValue<string>(/*sql*/`SELECT attributeId FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`,[
sourceNoteId,
name,
targetNoteId
@ -220,7 +220,7 @@ function deleteRelation(req: Request) {
consttargetNoteId=req.params.targetNoteId;
constname=req.params.name;
constattributeId=sql.getValue<string|null>(`SELECT attributeId FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`,[
constattributeId=sql.getValue<string|null>(/*sql*/`SELECT attributeId FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`,[
constbranchId=sql.getValue<string>(`SELECT branchId FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0`,[noteId,parentNoteId]);
constbranchId=sql.getValue<string>(/*sql*/`SELECT branchId FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0`,[noteId,parentNoteId]);
constentityChanges=sql.getRows<EntityChange>(`SELECT * FROM entity_changes WHERE entityName = ? AND SUBSTR(entityId, 1, 1) = ?`,[entityName,sector]);
constentityChanges=sql.getRows<EntityChange>(/*sql*/`SELECT * FROM entity_changes WHERE entityName = ? AND SUBSTR(entityId, 1, 1) = ?`,[entityName,sector]);
letentitiesInserted=entityChanges.length;
@ -125,7 +125,7 @@ function fillEntityChanges(entityName: string, entityPrimaryKey: string, conditi
@ -12,19 +12,19 @@ function eraseNotes(noteIdsToErase: string[]) {
return;
}
sql.executeMany(`DELETE FROM notes WHERE noteId IN (???)`,noteIdsToErase);
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'notes' AND entityId IN (???)`,noteIdsToErase));
sql.executeMany(/*sql*/`DELETE FROM notes WHERE noteId IN (???)`,noteIdsToErase);
setEntityChangesAsErased(sql.getManyRows(/*sql*/`SELECT * FROM entity_changes WHERE entityName = 'notes' AND entityId IN (???)`,noteIdsToErase));
// we also need to erase all "dependent" entities of the erased notes
constbranchIdsToErase=sql.getManyRows<{branchId: string}>(`SELECT branchId FROM branches WHERE noteId IN (???)`,noteIdsToErase).map((row)=>row.branchId);
constbranchIdsToErase=sql.getManyRows<{branchId: string}>(/*sql*/`SELECT branchId FROM branches WHERE noteId IN (???)`,noteIdsToErase).map((row)=>row.branchId);
eraseBranches(branchIdsToErase);
constattributeIdsToErase=sql.getManyRows<{attributeId: string}>(`SELECT attributeId FROM attributes WHERE noteId IN (???)`,noteIdsToErase).map((row)=>row.attributeId);
constattributeIdsToErase=sql.getManyRows<{attributeId: string}>(/*sql*/`SELECT attributeId FROM attributes WHERE noteId IN (???)`,noteIdsToErase).map((row)=>row.attributeId);
eraseAttributes(attributeIdsToErase);
constrevisionIdsToErase=sql.getManyRows<{revisionId: string}>(`SELECT revisionId FROM revisions WHERE noteId IN (???)`,noteIdsToErase).map((row)=>row.revisionId);
constrevisionIdsToErase=sql.getManyRows<{revisionId: string}>(/*sql*/`SELECT revisionId FROM revisions WHERE noteId IN (???)`,noteIdsToErase).map((row)=>row.revisionId);
eraseRevisions(revisionIdsToErase);
@ -47,9 +47,9 @@ function eraseBranches(branchIdsToErase: string[]) {
return;
}
sql.executeMany(`DELETE FROM branches WHERE branchId IN (???)`,branchIdsToErase);
sql.executeMany(/*sql*/`DELETE FROM branches WHERE branchId IN (???)`,branchIdsToErase);
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'branches' AND entityId IN (???)`,branchIdsToErase));
setEntityChangesAsErased(sql.getManyRows(/*sql*/`SELECT * FROM entity_changes WHERE entityName = 'branches' AND entityId IN (???)`,branchIdsToErase));
@ -59,9 +59,9 @@ function eraseAttributes(attributeIdsToErase: string[]) {
return;
}
sql.executeMany(`DELETE FROM attributes WHERE attributeId IN (???)`,attributeIdsToErase);
sql.executeMany(/*sql*/`DELETE FROM attributes WHERE attributeId IN (???)`,attributeIdsToErase);
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'attributes' AND entityId IN (???)`,attributeIdsToErase));
setEntityChangesAsErased(sql.getManyRows(/*sql*/`SELECT * FROM entity_changes WHERE entityName = 'attributes' AND entityId IN (???)`,attributeIdsToErase));
@ -71,9 +71,9 @@ function eraseAttachments(attachmentIdsToErase: string[]) {
return;
}
sql.executeMany(`DELETE FROM attachments WHERE attachmentId IN (???)`,attachmentIdsToErase);
sql.executeMany(/*sql*/`DELETE FROM attachments WHERE attachmentId IN (???)`,attachmentIdsToErase);
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'attachments' AND entityId IN (???)`,attachmentIdsToErase));
setEntityChangesAsErased(sql.getManyRows(/*sql*/`SELECT * FROM entity_changes WHERE entityName = 'attachments' AND entityId IN (???)`,attachmentIdsToErase));
@ -83,9 +83,9 @@ function eraseRevisions(revisionIdsToErase: string[]) {
return;
}
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`,revisionIdsToErase);
sql.executeMany(/*sql*/`DELETE FROM revisions WHERE revisionId IN (???)`,revisionIdsToErase);
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'revisions' AND entityId IN (???)`,revisionIdsToErase));
setEntityChangesAsErased(sql.getManyRows(/*sql*/`SELECT * FROM entity_changes WHERE entityName = 'revisions' AND entityId IN (???)`,revisionIdsToErase));
constlocalEC=sql.getRow<EntityChange|undefined>(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`,[remoteEC.entityName,remoteEC.entityId]);
constlocalEC=sql.getRow<EntityChange|undefined>(/*sql*/`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`,[remoteEC.entityName,remoteEC.entityId]);