Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
new @parentCount virtual search attribute, closes #738
zadam8e1f8c869b21
diff --git a/src/services/build_search_query.js b/src/services/build_search_query.jsindex 2f54afb76f..0bac8b4284 100644--- a/src/services/build_search_query.js+++ b/src/services/build_search_query.js@@ -11,7 +11,8 @@ const VIRTUAL_ATTRIBUTES = ["content","type","mime",- "text"+ "text",+ "parentCount"];module.exports = function(filters, selectedColumns = 'notes.*') {@@ -43,6 +44,11 @@ module.exports = function(filters, selectedColumns = 'notes.*') {accessor = `${alias}.${property}`;}+ else if (property === 'parentCount') {+ // need to cast as string for the equality operator to work+ // for >= etc. it is cast again to DECIMAL+ accessor = `CAST((SELECT COUNT(1) FROM branches WHERE branches.noteId = notes.noteId AND isDeleted = 0) AS STRING)`;+ }else {accessor = "notes." + property;}