diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html
index d1cd08ae6..c1b498d32 100644
--- a/docs/backend_api/BackendScriptApi.html
+++ b/docs/backend_api/BackendScriptApi.html
@@ -396,7 +396,7 @@ the backend.
Source:
@@ -1531,7 +1531,7 @@ JSON MIME type. See also createNote() for more options.
Source:
@@ -2763,7 +2763,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3441,6 +3441,112 @@ if some action needs to happen on only one specific instance.
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<(Note|null)>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getTodayNote() → {Promise.<(Note|null)>}
+
+
+
+
+
+
+
+ Returns today's day note. If such note doesn't exist, it is created.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Returns:
@@ -3594,7 +3700,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3749,7 +3855,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4402,7 +4508,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -4535,7 +4641,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -4910,7 +5016,7 @@ transactional by default.
Source:
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index 141ac6303..dabe2ae48 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -5523,6 +5523,156 @@ Cache is note instance scoped.
+
+
+
+
+
+
+ (async) isDescendantOfNote(ancestorNoteId) → {Promise.<boolean>}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ ancestorNoteId |
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ - true if ancestorNoteId occurs in at least one of the note's paths
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<boolean>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.html
index 4f4029bde..9f32a00ee 100644
--- a/docs/backend_api/entities_note.js.html
+++ b/docs/backend_api/entities_note.js.html
@@ -806,6 +806,16 @@ class Note extends Entity {
return notePaths;
}
+ /**
+ * @param ancestorNoteId
+ * @return {Promise<boolean>} - true if ancestorNoteId occurs in at least one of the note's paths
+ */
+ async isDescendantOfNote(ancestorNoteId) {
+ const notePaths = await this.getAllNotePaths();
+
+ return notePaths.some(path => path.includes(ancestorNoteId));
+ }
+
beforeSaving() {
if (!this.isDeleted) {
this.isDeleted = false;
@@ -846,6 +856,7 @@ class Note extends Entity {
delete pojo.isContentAvailable;
delete pojo.__attributeCache;
delete pojo.content;
+ /** zero references to contentHash, probably can be removed */
delete pojo.contentHash;
}
}
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html
index 725fe064e..edc16a682 100644
--- a/docs/backend_api/services_backend_script_api.js.html
+++ b/docs/backend_api/services_backend_script_api.js.html
@@ -282,6 +282,14 @@ function BackendScriptApi(currentNote, apiParams) {
*/
this.getDateNote = dateNoteService.getDateNote;
+ /**
+ * Returns today's day note. If such note doesn't exist, it is created.
+ *
+ * @method
+ * @returns {Promise<Note|null>}
+ */
+ this.getTodayNote = dateNoteService.getTodayNote;
+
/**
* Returns note for the first date of the week of the given date.
*
diff --git a/src/entities/note.js b/src/entities/note.js
index c89ea0f23..e9d4e1aba 100644
--- a/src/entities/note.js
+++ b/src/entities/note.js
@@ -778,6 +778,16 @@ class Note extends Entity {
return notePaths;
}
+ /**
+ * @param ancestorNoteId
+ * @return {Promise} - true if ancestorNoteId occurs in at least one of the note's paths
+ */
+ async isDescendantOfNote(ancestorNoteId) {
+ const notePaths = await this.getAllNotePaths();
+
+ return notePaths.some(path => path.includes(ancestorNoteId));
+ }
+
beforeSaving() {
if (!this.isDeleted) {
this.isDeleted = false;
diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js
index 36bb247ae..08e8890b5 100644
--- a/src/services/backend_script_api.js
+++ b/src/services/backend_script_api.js
@@ -254,6 +254,14 @@ function BackendScriptApi(currentNote, apiParams) {
*/
this.getDateNote = dateNoteService.getDateNote;
+ /**
+ * Returns today's day note. If such note doesn't exist, it is created.
+ *
+ * @method
+ * @returns {Promise}
+ */
+ this.getTodayNote = dateNoteService.getTodayNote;
+
/**
* Returns note for the first date of the week of the given date.
*
diff --git a/src/services/date_notes.js b/src/services/date_notes.js
index fffb62e4a..265048705 100644
--- a/src/services/date_notes.js
+++ b/src/services/date_notes.js
@@ -170,6 +170,10 @@ async function getDateNote(dateStr) {
return dateNote;
}
+async function getTodayNote() {
+ return await getDateNote(dateUtils.localNowDate());
+}
+
function getStartOfTheWeek(date, startOfTheWeek) {
const day = date.getDay();
let diff;
@@ -202,5 +206,6 @@ module.exports = {
getYearNote,
getMonthNote,
getWeekNote,
- getDateNote
+ getDateNote,
+ getTodayNote
};
\ No newline at end of file