import { queryByTemplate } from "https://deno.land/x/earthstar@v10.2.0/src/entries/npm.ts";
Given a template string like "/posts/{postId}.json", query the replica for docs with matching paths.
See the docs for matchTemplateAndPath for details on template strings.
You can get the variables out of your document paths like this:
let template = '/posts/{postId}.json';
let docs = await queryByTemplate(myReplica, template);
for (let doc of docs) {
// vars will be like { postId: 'abc' }
let vars = extractTemplateVariablesFromPath(template, doc.path);
}
Type Parameters
optional
F = DefaultFormatsParameters
replica: Replica
optional
moreQueryOptions: Omit<Query<[string]>, "formats"> = [UNSUPPORTED]optional
formats: FormatsArg<F>Returns
Promise<FormatDocType<F>[]>