Support filtering relationships by _id
This commit is contained in:
parent
3517f8cbc1
commit
a959a26d60
|
@ -3553,6 +3553,28 @@ if (descriptions.length) {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
}).toContainExactly([row])
|
}).toContainExactly([row])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("can filter by the related _id", async () => {
|
||||||
|
await expectSearch({
|
||||||
|
query: {
|
||||||
|
equal: { "rel._id": row.rel[0]._id },
|
||||||
|
},
|
||||||
|
}).toContainExactly([row])
|
||||||
|
|
||||||
|
await expectSearch({
|
||||||
|
query: {
|
||||||
|
equal: { "rel._id": row.rel[1]._id },
|
||||||
|
},
|
||||||
|
}).toContainExactly([row])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("can filter by the related _id and find nothing", async () => {
|
||||||
|
await expectSearch({
|
||||||
|
query: {
|
||||||
|
equal: { "rel._id": "rel_none" },
|
||||||
|
},
|
||||||
|
}).toFindNothing()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
!isInternal &&
|
!isInternal &&
|
||||||
|
|
|
@ -69,7 +69,8 @@ export const getQueryableFields = async (
|
||||||
fromTables: string[],
|
fromTables: string[],
|
||||||
opts?: { noRelationships?: boolean }
|
opts?: { noRelationships?: boolean }
|
||||||
): Promise<string[]> => {
|
): Promise<string[]> => {
|
||||||
const result = []
|
// Querying by _id is always allowed, even if it's never part of the schema
|
||||||
|
const result = ["_id"]
|
||||||
for (const field of Object.keys(table.schema).filter(
|
for (const field of Object.keys(table.schema).filter(
|
||||||
f => allowedFields.includes(f) && table.schema[f].visible !== false
|
f => allowedFields.includes(f) && table.schema[f].visible !== false
|
||||||
)) {
|
)) {
|
||||||
|
@ -113,9 +114,7 @@ export const getQueryableFields = async (
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = [
|
const result = []
|
||||||
"_id", // Querying by _id is always allowed, even if it's never part of the schema
|
|
||||||
]
|
|
||||||
|
|
||||||
if (fields == null) {
|
if (fields == null) {
|
||||||
fields = Object.keys(table.schema)
|
fields = Object.keys(table.schema)
|
||||||
|
|
Loading…
Reference in New Issue