Skip to content

Commit

Permalink
update (note relation): return noteId and parentId from the sql query
Browse files Browse the repository at this point in the history
  • Loading branch information
dependentmadani committed Oct 16, 2024
1 parent 7bfe0eb commit dd1bcdc
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,15 @@ export default class NoteRelationsSequelizeStorage {
FROM ${String(this.database.literal(this.tableName).val)} nr
INNER JOIN note_parents np ON np.parent_id = nr.note_id
)
SELECT np.note_id, np.parent_id
SELECT np.note_id AS "noteId", np.parent_id AS "parentId"
FROM note_parents np;`;

const result = await this.database.query(query, {
const result = await this.model.sequelize?.query(query, {
replacements: { startNoteId: noteId },
type: QueryTypes.SELECT,
});

// eslint-disable-next-line @typescript-eslint/naming-convention
let noteParents = (result as { note_id: number; parent_id: number }[])?.map(note => note.parent_id) ?? [];
let noteParents = (result as { noteId: number; parentId: number }[])?.map(note => note.parentId) ?? [];

noteParents.reverse();

Expand Down

0 comments on commit dd1bcdc

Please sign in to comment.