Skip to content

Commit ed08016

Browse files
committed
fix: fixed shelter OR and AND conditions
1 parent 520cdc5 commit ed08016

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/shelter/ShelterSearch.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ShelterSearch {
1313
}
1414

1515
get priority(): Prisma.ShelterWhereInput[] {
16-
if (this.data.priority !== null) {
16+
if (this.data.priority) {
1717
return [
1818
{
1919
shelterSupplies: {
@@ -102,15 +102,17 @@ class ShelterSearch {
102102

103103
get query(): Prisma.ShelterWhereInput {
104104
if (Object.keys(this.data).length === 0) return {};
105-
return {
106-
OR: [
107-
...this.search,
108-
...this.shelterStatus,
105+
const queryData = {
106+
AND: [
107+
{ OR: this.search },
108+
{ OR: this.shelterStatus },
109+
{ OR: this.priority },
109110
this.supplyCategoryIds,
110111
this.supplyIds,
111-
...this.search,
112112
],
113113
};
114+
console.log(JSON.stringify(queryData, null, 2));
115+
return queryData;
114116
}
115117
}
116118

0 commit comments

Comments
 (0)