Nishil FalduN
Convex Community12mo ago
15 replies
Nishil Faldu

Table Aggregrate Component Question

likes: defineTable({
    userId: v.id('users'),
    parentId: v.union(
      v.id('posts'),
      v.id('discussions'),
      v.id('events'),
      v.id('comments')
    ),
    parentType: v.union(
      v.literal('posts'),
      v.literal('discussions'),
      v.literal('events'),
      v.literal('comments')
    ),
    
    universityId: v.id('universities'),
  })
    .index('byParentIdAndUserId', ['parentId', 'userId'])
    .index('byParentId', ['parentId']),

How would I generally write the TableAggregrate component for this? I am very confused and I can't seem to understand or figure it out. My goal is to count number of likes from an input of university id
Was this page helpful?