mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
new @parentCount virtual search attribute, closes #738
This commit is contained in:
parent
0e2f8b5734
commit
8e1f8c869b
@ -11,7 +11,8 @@ const VIRTUAL_ATTRIBUTES = [
|
|||||||
"content",
|
"content",
|
||||||
"type",
|
"type",
|
||||||
"mime",
|
"mime",
|
||||||
"text"
|
"text",
|
||||||
|
"parentCount"
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = function(filters, selectedColumns = 'notes.*') {
|
module.exports = function(filters, selectedColumns = 'notes.*') {
|
||||||
@ -43,6 +44,11 @@ module.exports = function(filters, selectedColumns = 'notes.*') {
|
|||||||
|
|
||||||
accessor = `${alias}.${property}`;
|
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 {
|
else {
|
||||||
accessor = "notes." + property;
|
accessor = "notes." + property;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user