Build Drive search queries (the q parameter of list-files) without hand-escaping. String values are single-quoted with \\ and ' escaped; terms combine with all-of, any-of and negate. See https://developers.google.com/workspace/drive/api/guides/ref-search-terms.

::q ::google::drive::query

q ::q/all-of(
  ::q/in-folder("1AbCfolder"),
  ::q/any-of(::q/mime-type-is(::google::drive/DOCUMENT_MIME), ::q/mime-type-is("application/pdf")),
  ::q/modified-after("2026-10-01T00:00:00Z"),
  ::q/not-trashed()
)
// "'1AbCfolder' in parents and (mimeType = 'application/vnd.google-apps.document'
//   or mimeType = 'application/pdf') and modifiedTime > '2026-10-01T00:00:00Z'
//   and trashed = false"

Values

BACKSLASH

BACKSLASH: Str "\\"

QUOTE

QUOTE: Str "'"

Functions

all-of

fn (...terms: Any): Str

Join terms with and. Empty or null terms are skipped; compound terms (containing and/or) are parenthesised.

Example

::google::drive::query/all-of(::google::drive::query/name-contains("Q3"), ::google::drive::query/not-trashed())
// "name contains 'Q3' and trashed = false"

// Empty and null terms are skipped
::google::drive::query/all-of(::google::drive::query/starred(), null)  // "starred = true"

any-of

fn (...terms: Any): Str

Join terms with or. Empty or null terms are skipped; compound terms are parenthesised, and all-of parenthesises the result when you combine it further.

Example

::google::drive::query/any-of(::google::drive::query/starred(), ::google::drive::query/shared-with-me())
// "starred = true or sharedWithMe = true"

app-property

fn (key: Str, value: Str): Str

appProperties has { key='k' and value='v' } (private to your OAuth client).

Example

::google::drive::query/app-property("job", "42")  // "appProperties has { key='job' and value='42' }"

created-after

fn (timestamp: Str): Str

createdTime > '<RFC 3339>'.

Example

::google::drive::query/created-after("2026-10-01T00:00:00Z")  // "createdTime > '2026-10-01T00:00:00Z'"

full-text-contains

fn (text: Str): Str

fullText contains '...' (name, description, indexable text and content; whole tokens). Wrap the text in double quotes for a phrase.

Example

::google::drive::query/full-text-contains("budget")  // "fullText contains 'budget'"

has-property

fn (key: Str, value: Str): Str

properties has { key='k' and value='v' } (public custom properties). Use app-property for appProperties.

Example

::google::drive::query/has-property("team", "eng")  // "properties has { key='team' and value='eng' }"

in-folder

fn (folder-id: Str): Str

'<id>' in parents: direct children of a folder (not descendants).

Example

::google::drive::query/in-folder("1AbCfolder")  // "'1AbCfolder' in parents"

in-parents

fn (folder-id: Str): Str

Alias of in-folder.

Example

::google::drive::query/in-parents("1AbCfolder")  // "'1AbCfolder' in parents"

is-folder

fn (): Str

Folders only.

Example

::google::drive::query/is-folder()  // "mimeType = 'application/vnd.google-apps.folder'"

mime-type-is

fn (mime-type: Str): Str

mimeType = '...'.

Example

::google::drive::query/mime-type-is("application/pdf")  // "mimeType = 'application/pdf'"

mime-type-is-not

fn (mime-type: Str): Str

mimeType != '...'.

Example

::google::drive::query/mime-type-is-not("application/pdf")  // "mimeType != 'application/pdf'"

modified-after

fn (timestamp: Str): Str

modifiedTime > '<RFC 3339>', e.g. "2026-10-01T00:00:00Z" (UTC unless an offset is given).

Example

::google::drive::query/modified-after("2026-10-01T00:00:00Z")  // "modifiedTime > '2026-10-01T00:00:00Z'"

modified-before

fn (timestamp: Str): Str

modifiedTime < '<RFC 3339>'.

Example

::google::drive::query/modified-before("2026-10-01T00:00:00Z")  // "modifiedTime < '2026-10-01T00:00:00Z'"

name-contains

fn (text: Str): Str

name contains '...' (Drive matches name prefixes / word starts).

Example

::google::drive::query/name-contains("roadmap")  // "name contains 'roadmap'"

name-is

fn (name: Str): Str

name = '...' (exact name).

Example

::google::drive::query/name-is("a.txt")  // "name = 'a.txt'"

negate

fn (term: Str): Str

not (<term>).

Example

::google::drive::query/negate(::google::drive::query/starred())  // "not (starred = true)"

not-folder

fn (): Str

Everything except folders.

Example

::google::drive::query/not-folder()  // "mimeType != 'application/vnd.google-apps.folder'"

not-trashed

fn (): Str

trashed = false. Drive includes trashed files unless you ask otherwise.

Example

::google::drive::query/not-trashed()  // "trashed = false"

owned-by

fn (email: Str): Str

'<email>' in owners.

Example

::google::drive::query/owned-by("ada@example.com")  // "'ada@example.com' in owners"

quote

fn (value: Str): Str

Quote a string value for a Drive query: wraps in single quotes, escaping \\ as \\\\ and ' as \\'. quote("Valentine's Day") is 'Valentine\\'s Day'.

Example

::google::drive::query/quote("a.txt")  // "'a.txt'"
::google::drive::query/quote("Valentine's Day")  // "'Valentine\\'s Day'"

shared-with-me

fn (): Str

sharedWithMe = true.

Example

::google::drive::query/shared-with-me()  // "sharedWithMe = true"

shortcut-to

fn (target-id: Str): Str

shortcutDetails.targetId = '<id>': shortcuts pointing at a file.

Example

::google::drive::query/shortcut-to("1AbCfile")  // "shortcutDetails.targetId = '1AbCfile'"

starred

fn (): Str

starred = true.

Example

::google::drive::query/starred()  // "starred = true"

term

fn (field: Str, operator: Str, value: Str): Str

A raw field operator 'value' term with the value quoted, e.g. term("name", "=", "a.txt"). Escape hatch for terms without a helper.

Example

::google::drive::query/term("name", "=", "a.txt")  // "name = 'a.txt'"

trashed

fn (): Str

trashed = true.

Example

::google::drive::query/trashed()  // "trashed = true"