Constructor
new Note(id, title, content, createdAt, updatedAt, deletedAt) → {Note}
Create a new Note instance
Parameters:
Name | Type | Default | Description |
---|---|---|---|
id |
string | null | Unique identifier for the note |
title |
string | Title of the note |
|
content |
string | Content of the note |
|
createdAt |
Date | Date when the note was created |
|
updatedAt |
Date | Date when the note was last updated |
|
deletedAt |
Date | null | null | Date when the note was deleted (null if not deleted) |
- Source:
Returns:
New Note instance
- Type
- Note
Example
const note = new Note('123', 'My Note', 'Note content', new Date(), new Date(), null);
Classes
Methods
isActive() → {boolean}
Check if the note is active (not deleted)
- Source:
Returns:
True if the note is active, false otherwise
- Type
- boolean
isDeleted() → {boolean}
Check if the note is deleted
- Source:
Returns:
True if the note is deleted, false otherwise
- Type
- boolean
toObject() → {Object}
Convert the Note instance to a plain object
- Source:
Returns:
- Plain object representation of the note
- Type
- Object
Example
const note = new Note('123', 'Title', 'Content');
const obj = note.toObject();
// Returns: { id: '123', title: 'Title', content: 'Content', createdAt: Date, updatedAt: Date, deletedAt: null }
(static) fromObject(obj) → {Note}
Create a Note instance from a plain object
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Plain object with note properties |
- Source:
Returns:
- New Note instance
- Type
- Note
Example
const note = Note.fromObject({
id: 'note_123',
title: 'Sample Note',
content: 'This is a sample note',
createdAt: '2023-01-01T00:00:00.000Z',
updatedAt: '2023-01-02T00:00:00.000Z',
deletedAt: null
});