@@ -90,6 +90,19 @@ def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
90
90
If the argument is `True`, only include tasks _with_ a due date.
91
91
If the argument is `None` (default), then include all tasks.
92
92
93
+ search_query : str, optional
94
+ The string value is passed to the SQL LIKE operator. It can thus
95
+ include placeholders such as '%' and '_'. Per default, it is
96
+ wrapped in '% ... %'.
97
+
98
+ Currently titles and notes of to-dos, projects, headings, and areas
99
+ are taken into account.
100
+
101
+ If the query is `False`, then return items where titles or notes
102
+ are empty.
103
+
104
+ If the query `None`, then return all items.
105
+
93
106
index : {'index', 'todayIndex'}, default 'index'
94
107
Database field to order result by.
95
108
@@ -315,26 +328,35 @@ def tags(title=None, include_items=False, **kwargs):
315
328
# Utility API functions derived from above
316
329
# --------------------------------------------------
317
330
331
+
318
332
def search (query : str , ** kwargs ) -> List [Dict ]:
319
333
"""
320
- Search the database. This takes mainly notes and titles into account .
334
+ Search tasks in the database .
321
335
322
- Parameters
323
- ----------
324
- query : str
325
- The string with optional placeholders (%) to search for.
336
+ Currently any part of a title and note of a to-do, project,
337
+ heading, or area is matched.
326
338
327
- Returns
328
- -------
329
- list of dict
330
- Representing Things items.
339
+ See the `search_query` parameter of `api.tasks` for details.
331
340
332
341
Examples
333
342
--------
334
- >>> things.search('substring % within notes and titles')
335
- ...
343
+ >>> things.search('book')
344
+ [{'uuid': 'YrOmUnEXASmpq8ch6RsyPt',
345
+ 'type': 'to-do',
346
+ 'title': 'Book a hotel room',
347
+ ...},
348
+ {'uuid': 'KVHAxIIJ52a0h1RCbmg5D6',
349
+ 'type': 'to-do',
350
+ 'title': 'Book flights',
351
+ ...}]
352
+
353
+ >>> things.search('book%room')
354
+ [{'uuid': 'YrOmUnEXASmpq8ch6RsyPt',
355
+ 'type': 'to-do',
356
+ 'title': 'Book a hotel room',
357
+ ...}]
336
358
"""
337
- return tasks (querystr = query , ** kwargs )
359
+ return tasks (search_query = query , ** kwargs )
338
360
339
361
340
362
def get (uuid , default = None , ** kwargs ):
0 commit comments