File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export const find: Find = async function find(
15
15
{
16
16
collection,
17
17
joins = { } ,
18
- limit,
18
+ limit = 0 ,
19
19
locale,
20
20
page,
21
21
pagination,
Original file line number Diff line number Diff line change @@ -111,9 +111,10 @@ export const buildJoinAggregation = async ({
111
111
input : `$${ as } .docs` ,
112
112
} ,
113
113
} , // Slicing the docs to match the limit
114
- [ `${ as } .hasNextPage` ] : {
115
- $gt : [ { $size : `$${ as } .docs` } , limitJoin || Number . MAX_VALUE ] ,
116
- } , // Boolean indicating if more docs than limit
114
+ [ `${ as } .hasNextPage` ] : limitJoin
115
+ ? { $gt : [ { $size : `$${ as } .docs` } , limitJoin ] }
116
+ : false ,
117
+ // Boolean indicating if more docs than limit
117
118
} ,
118
119
} ,
119
120
)
Original file line number Diff line number Diff line change @@ -117,6 +117,9 @@ describe('Joins Field', () => {
117
117
it ( 'should populate joins using find' , async ( ) => {
118
118
const result = await payload . find ( {
119
119
collection : 'categories' ,
120
+ where : {
121
+ id : { equals : category . id } ,
122
+ } ,
120
123
} )
121
124
122
125
const [ categoryWithPosts ] = result . docs
@@ -126,6 +129,29 @@ describe('Joins Field', () => {
126
129
expect ( categoryWithPosts . group . relatedPosts . docs [ 0 ] . title ) . toBe ( 'test 14' )
127
130
} )
128
131
132
+ it ( 'should not error when deleting documents with joins' , async ( ) => {
133
+ const category = await payload . create ( {
134
+ collection : 'categories' ,
135
+ data : {
136
+ name : 'category with post' ,
137
+ } ,
138
+ } )
139
+
140
+ const post = await createPost ( {
141
+ category : category . id ,
142
+ } )
143
+
144
+ const result = await payload . delete ( {
145
+ collection : 'categories' ,
146
+ // id: category.id,
147
+ where : {
148
+ id : { equals : category . id } ,
149
+ } ,
150
+ } )
151
+
152
+ expect ( result . docs [ 0 ] . id ) . toStrictEqual ( category . id )
153
+ } )
154
+
129
155
describe ( 'Joins with localization' , ( ) => {
130
156
let localizedCategory : Category
131
157
You can’t perform that action at this time.
0 commit comments