sanity documents query *[_id in path("/somePath")] currently returning bad pattern
The issue with your query is that the command-line is interpreting the parentheses in path("/somePath") as special shell characters. You need to escape or quote your query properly.
Here are a few solutions:
Option 1: Use single quotes around the entire query
sanity documents query '*[_id in path("/somePath")]'Option 2: Escape the parentheses
sanity documents query "*[_id in path\(\"/somePath\"\)]"Option 3: Use double quotes and escape inner quotes
sanity documents query "*[_id in path(\"/somePath\")]"The path() function in GROQ is really useful for filtering documents by their ID path. Here's how it works:
*[_id in path("a.b.c.*")]matches IDs likea.b.c.dbut nota.b.c.d.e(single level)*[_id in path("a.b.c.**")]matchesa.b.c.dand also deeper paths likea.b.c.d.e.f.g(all levels)*[!(_id in path("a.b.c.**"))]matches anything NOT under that path
You can also use path() for common patterns like getting all drafts:
*[_id in path("drafts.**")]The shell escaping issue is a common gotcha when running GROQ queries from the command line - always wrap your queries in quotes to prevent the shell from interpreting special characters! The single quotes option (Option 1) is usually the safest bet since it prevents the shell from interpreting anything inside.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.