Skip to content

Commit

Permalink
Fix some variables name, also fix descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
elizachi committed Jan 6, 2024
1 parent 815fa98 commit 49a88d9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/domain/service/noteRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class NoteRelationshipService {
*/
public async addNoteRelation(noteId: Note['id'], parentId: Note['id'] | undefined): Promise<boolean> {
/**
* If parent id not passed returned false
* If parent id not passed returned false - in this case the current note will not have a parent note field
*/
if (parentId === undefined) {
return false;
Expand Down Expand Up @@ -64,7 +64,7 @@ export default class NoteRelationshipService {
*
* @param noteId - id of the current note
*/
public async getParentNoteByNoteId(noteId: Note['id']): Promise<number | null> {
public async getParentNoteIdByNoteId(noteId: Note['id']): Promise<number | null> {
return await this.repository.getParentNoteByNoteId(noteId);
}
}
2 changes: 1 addition & 1 deletion src/presentation/http/router/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const NoteRouter: FastifyPluginCallback<NoteRouterOptions> = (fastify, opts, don
return reply.notFound('Note not found');
}

const parentId = await noteRelationspipService.getParentNoteByNoteId(note.id);
const parentId = await noteRelationspipService.getParentNoteIdByNoteId(note.id);

const parentNote = parentId !== null ? await noteService.getNoteById(parentId) : undefined;
/**
Expand Down
2 changes: 1 addition & 1 deletion src/repository/noteRelationship.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class NoteRelationshipRepository {
}

/**
* Add note relation
* Create new child-parent note relation
*
* @param noteId - id of the current note
* @param parentId - id of the parent note
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,26 @@ export default class NoteRelationshipSequelizeStorage {
* @param parentId - id of the parent note
*/
public async createNoteRelation(noteId: NoteInternalId, parentId: NoteInternalId): Promise<boolean> {
const entryId = await this.model.create({
const newRelation = await this.model.create({
noteId,
parentId,
});

return entryId.id !== undefined;
return newRelation.id !== undefined;
}

/**
* Gets parent note id by note id
*
* @param parentId - parent note id
* @returns { Promise<Note | null> } found note
*/
public async getParentNoteByNoteId(parentId: NoteInternalId): Promise<number | null> {
const finded = await this.model.findOne({
const found = await this.model.findOne({
where: {
parentId,
},
});
const parentNoteId = finded?.parentId;
const parentNoteId = found?.parentId;

return parentNoteId !== undefined ? parentNoteId : null;
};
Expand Down

0 comments on commit 49a88d9

Please sign in to comment.