Class: NoteRepository

NoteRepository()

Interface for a Note repository. This defines the contract that any database implementation must follow.

Constructor

new NoteRepository()

Source:

Methods

(async) countDeleted() → {Promise.<number>}

Count the number of deleted notes in recycle bin

Source:
Returns:

Promise resolving to the count of deleted notes

Type
Promise.<number>

(async) create(note) → {Promise.<Object>}

Create a new note

Parameters:
Name Type Description
note Object

The note to create

Source:
Returns:

Promise resolving to the created Note object

Type
Promise.<Object>

(async) emptyRecycleBin() → {Promise.<number>}

Empty the recycle bin by permanently deleting all deleted notes

Source:
Returns:

Promise resolving to the number of notes permanently deleted

Type
Promise.<number>

(async) findAll() → {Promise.<Array>}

Find all active notes (not deleted)

Source:
Returns:

Promise resolving to an array of active Note objects

Type
Promise.<Array>

(async) findAllIncludingDeleted() → {Promise.<Array>}

Find all notes regardless of deletion status

Source:
Returns:

Promise resolving to an array of all Note objects

Type
Promise.<Array>

(async) findById(id) → {Promise.<(Object|null)>}

Find a note by its ID

Parameters:
Name Type Description
id string

The ID of the note to find

Source:
Returns:

Promise resolving to a Note object or null if not found

Type
Promise.<(Object|null)>

(async) findDeleted() → {Promise.<Array>}

Find all deleted notes (in recycle bin)

Source:
Returns:

Promise resolving to an array of deleted Note objects

Type
Promise.<Array>

(async) moveToRecycleBin(id) → {Promise.<boolean>}

Move a note to recycle bin (soft delete)

Parameters:
Name Type Description
id string

The ID of the note to move to recycle bin

Source:
Returns:

Promise resolving to true if moved to recycle bin, false if not found

Type
Promise.<boolean>

(async) permanentDelete(id) → {Promise.<boolean>}

Permanently delete a note

Parameters:
Name Type Description
id string

The ID of the note to permanently delete

Source:
Returns:

Promise resolving to true if deleted, false if not found

Type
Promise.<boolean>

(async) restore(id) → {Promise.<boolean>}

Restore a note from recycle bin

Parameters:
Name Type Description
id string

The ID of the note to restore

Source:
Returns:

Promise resolving to true if restored, false if not found

Type
Promise.<boolean>

(async) restoreAll() → {Promise.<number>}

Restore all notes from recycle bin

Source:
Returns:

Promise resolving to the number of notes restored

Type
Promise.<number>

(async) update(id, note) → {Promise.<(Object|null)>}

Update an existing note

Parameters:
Name Type Description
id string

The ID of the note to update

note Object

The updated note data

Source:
Returns:

Promise resolving to the updated Note object or null if not found

Type
Promise.<(Object|null)>