Hi, I have a question about nesting includes and s...
# orm-help
m
Hi, I have a question about nesting includes and selects. As an example, I have Table A with several feeds including a relation field that connects it to Table B. If I say
Copy code
...
				return ctx.prisma.TableA
					.findMany({
						where: {
							...
						},
						include: {
							TableBconnectionField: true					},
					})
...
I get all the fields in Table A and all the fields in Table B. But I also have a connection field in Table B to Table C and I need some data from that included in the return JSON as well. If I put
Copy code
...
				return ctx.prisma.TableA
					.findMany({
						where: {
							...
						},
						include: {
							TableBconnectionField: {
								select: { field_1: true, field_2: true, TableCconnectionField: true },
							}
						},
					})
...
I get all the fields for Tables A and C but only get field_1 and field_2 for Table B. Is there a way to do this that gives me all the fields for Table B as well without me having to explicitly request them?
After some more playing around, it looks like nesting an include inside an include works if I write it correctly. I didn't see any in the examples in the documentation, but it seems to work.
I'm guessing the caveat with this is that the return data can get exponentially large if you're not judicious with its usage.