feat: query blocks

This commit is contained in:
DarkSky 2022-08-04 17:53:59 +08:00
parent c4e39980c6
commit e46da42fac

View File

@ -305,6 +305,18 @@ export class BlockClient<
return this._blockIndexer.query(query); return this._blockIndexer.query(query);
} }
public queryBlocks(query: QueryIndexMetadata): Promise<BlockSearchItem[]> {
const ids = this.query(query);
return Promise.all(
this._blockIndexer.getMetadata(ids).map(async page => ({
content: this.get_decoded_content(
await this._adapter.getBlock(page.id)
),
...page,
}))
);
}
/** /**
* Get a fixed name, which has the same UUID in each workspace, and is automatically created when it does not exist * Get a fixed name, which has the same UUID in each workspace, and is automatically created when it does not exist
* Generally used to store workspace-level global configuration * Generally used to store workspace-level global configuration