mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
adding where and with to read many
This commit is contained in:
@@ -169,6 +169,7 @@ export function serveStaticViaImport(opts?: { manifest?: Manifest }) {
|
|||||||
if (files.includes(path)) {
|
if (files.includes(path)) {
|
||||||
try {
|
try {
|
||||||
const content = await import(`bknd/static/${path}?raw`, {
|
const content = await import(`bknd/static/${path}?raw`, {
|
||||||
|
/* @vite-ignore */
|
||||||
assert: { type: "text" },
|
assert: { type: "text" },
|
||||||
}).then((m) => m.default);
|
}).then((m) => m.default);
|
||||||
|
|
||||||
|
|||||||
@@ -256,10 +256,12 @@ export class DataController extends Controller {
|
|||||||
// read many
|
// read many
|
||||||
const saveRepoQuery = s
|
const saveRepoQuery = s
|
||||||
.object({
|
.object({
|
||||||
...omitKeys(repoQuery.properties, ["with"]),
|
...omitKeys(repoQuery.properties, ["with", "where"]),
|
||||||
sort: s.string({ default: "id" }),
|
sort: s.string({ default: "id" }),
|
||||||
select: s.array(s.string()),
|
select: s.array(s.string()),
|
||||||
join: s.array(s.string()),
|
join: s.array(s.string()),
|
||||||
|
with: s.anyOf([s.array(s.string()), s.record(s.object({}))]),
|
||||||
|
where: s.object({}),
|
||||||
})
|
})
|
||||||
.partial();
|
.partial();
|
||||||
const saveRepoQueryParams = (pick: string[] = Object.keys(repoQuery.properties)) => [
|
const saveRepoQueryParams = (pick: string[] = Object.keys(repoQuery.properties)) => [
|
||||||
@@ -273,7 +275,15 @@ export class DataController extends Controller {
|
|||||||
"/:entity",
|
"/:entity",
|
||||||
describeRoute({
|
describeRoute({
|
||||||
summary: "Read many",
|
summary: "Read many",
|
||||||
parameters: saveRepoQueryParams(["limit", "offset", "sort", "select", "join"]),
|
parameters: saveRepoQueryParams([
|
||||||
|
"limit",
|
||||||
|
"offset",
|
||||||
|
"sort",
|
||||||
|
"select",
|
||||||
|
"join",
|
||||||
|
"with",
|
||||||
|
"where",
|
||||||
|
]),
|
||||||
tags: ["data"],
|
tags: ["data"],
|
||||||
}),
|
}),
|
||||||
permission(DataPermissions.entityRead),
|
permission(DataPermissions.entityRead),
|
||||||
|
|||||||
Reference in New Issue
Block a user