Copium Dealer
07/07/2021, 2:08 PMRyan
07/07/2021, 2:10 PMCopium Dealer
07/07/2021, 2:12 PMCopium Dealer
07/07/2021, 2:12 PMRyan
07/07/2021, 2:14 PMCopium Dealer
07/07/2021, 2:16 PMCopium Dealer
07/07/2021, 2:17 PMRyan
07/07/2021, 2:18 PMCopium Dealer
07/07/2021, 2:18 PMCopium Dealer
07/07/2021, 2:18 PMRyan
07/07/2021, 2:19 PMCopium Dealer
07/07/2021, 2:19 PMRyan
07/07/2021, 2:20 PMCopium Dealer
07/07/2021, 2:21 PMCopium Dealer
07/07/2021, 2:21 PMRyan
07/07/2021, 2:21 PMRyan
07/07/2021, 2:22 PMI guess because they are preview features. But stuff about counting relations, ordering by relations etc.Is this regarding the docs?
Copium Dealer
07/07/2021, 2:22 PMCopium Dealer
07/07/2021, 2:22 PMconst results = await prisma.token.findMany({
select: {
id: true,
name: true,
symbol: true,
telegram: true,
votes: { where: { createdAt: { gt: subDays(new Date(), 1) } } },
_count: { select: { votes: true } },
},
orderBy: { votes: { count: "desc" } },
});Copium Dealer
07/07/2021, 2:23 PMvote set). I'm not sure if this is a bug, or intentional.Copium Dealer
07/07/2021, 2:25 PMRyan
07/07/2021, 2:28 PM“It’s the same request” Sorry I don’t understandBasically you would want filtering on aggregates i.e. in this case the count of the votes should match the filters in the
where clause.Copium Dealer
07/07/2021, 2:29 PMRyan
07/07/2021, 2:30 PMLike the code snippet I just sent)The one above? We have mostly everything covered in the docs related to preview features. If somethings not working, it’s most likely that it isn’t supported. Also TypeScript and
ctrl+space can help you with the parameters that the API accepts 🙂Ryan
07/07/2021, 2:31 PMRight. Do you mind providing an example? If that’s no trouble for youYeah this is similar to the one you posted in the main question. Filtering on aggregates is not yet supported so the above query will not give you the required result as the count wouldn’t take the
where condition into account.Copium Dealer
07/07/2021, 2:40 PMRyan
07/07/2021, 2:44 PMCopium Dealer
07/07/2021, 2:56 PMtoken object. Set this to true when votes reach 500. The only way I can see in the docs is through a middleware, or a cron job. Are there any better solutions that are more robust?