Add backend filter for field name

This commit is contained in:
RumovZ 2021-01-28 19:48:01 +01:00
parent a930aa41f0
commit d33442f901
3 changed files with 9 additions and 0 deletions

View File

@ -505,6 +505,7 @@ class Collection:
added_in: Optional[int] = None,
due_in: Optional[int] = None,
nids: Optional[List[int]] = None,
field_name: Optional[str] = None,
) -> str:
filters = searches or []
@ -532,6 +533,8 @@ class Collection:
append_filter(FilterToSearchIn(due_in=due_in))
if nids:
append_filter(FilterToSearchIn(nids=NoteIDs(nids=nids)))
if field_name:
append_filter(FilterToSearchIn(field_name=field_name))
if concat_by_or:
sep = ConcatSeparator.OR
else:

View File

@ -802,6 +802,7 @@ message FilterToSearchIn {
// will be due in the next x days
int32 due_in = 9;
NoteIDs nids = 10;
string field_name = 11;
}
}

View File

@ -351,6 +351,11 @@ impl From<pb::FilterToSearchIn> for Node<'_> {
kind: PropertyKind::Due(i),
}),
Filter::Nids(nids) => Node::Search(SearchNode::NoteIDs(nids.into_id_string().into())),
Filter::FieldName(s) => Node::Search(SearchNode::SingleField {
field: escape_anki_wildcards(&s).into_owned().into(),
text: "*".to_string().into(),
is_re: false,
}),
}
}
}