Draft.query or workspace.tagfilter untagged?

I’d like to create queries or workspaces that include “untagged” as an option. For instance:

Show me all Drafts with either TagA or are untagged.
Or conversely, show me Drafts created today as long as they aren’t untagged.

It doesn’t seem like this is possible, but I wanted to ask in case I’m missing something about the tagFilter or query syntax.

The query method does not have a flag for searching via “any | all” of the provided tags. You can do it using a workspace, however.

You can configure a workspace that looks for untagged, TagA, with the “Any” option selected, and query based on the workspace - or you can create a temporary workspace in the code to do this as well:

// do this if you have the workspace setup in the UI
let ws = Workspace.find("My Workspace");

// or this in code...
let ws = new Workspace();
ws.tagFilter = "untagged, TagA";
ws.tagFilterRequireAll = false;

// then query...
let drafts = ws.query("inbox"); // or "archive", "all"


1 Like

Does !untagged work as well (returning drafts with any tag)?

I think !untagged would work, but use tagged. See: https://docs.getdrafts.com/docs/drafts/filtering#tag-filters

1 Like

Gotcha. Thanks! …