or is it possible to use a field as a filter for a...
# orm-help
e
or is it possible to use a field as a filter for a subinclude? I need to do this
Copy code
const effects = await prisma.transactionEffect.findMany({
        where: {
            assetBalance: {
                wallet: {
                    id: wallet?.id,
                },
                asset: {
                    symbol: assetBalance?.asset?.symbol,
                },
            },
        },
        orderBy: {
            transaction: {
                blockNumber: 'desc',
            },
        },
        include: {
            transaction: true,
            assetBalance: {
                include: {
                    asset: {
                        include: {
                            assetPrice: {
                                where: {
                                    blockDate: // must be equal to transaction.timestamp (datetime) formatted as MM/dd/yyyy
                                }
                            }
                        }
                    }
                }
            }
        },
    });
👀 1
n
Your schema file would also help in this case as well. But can’t you use the where condition in the first where clause itself? So like
Copy code
where: {
            assetBalance: {
                wallet: {
                    id: wallet?.id,
                },
                asset: {
                    symbol: assetBalance?.asset?.symbol
                    assetPrice:'transaction.timestamp (datetime)'
                },
            },
        },
v
👋 Hello @Emanuele Ricci did you have have a chance to check Nurul's recommendation? Let us know if this is still an open question!