convex-js
convex-js copied to clipboard
request: add computed values in the db
Pretty much the title, if we could have computed values in the database level, it would make filtering much easier,
Example:
posts: defineTable({
ratings: v.array(v.number())
}, {
computed: { avarageRating: ({ratings) => ratings.reduce(...) / rating.length ?? 1))}
})
// filtering based on avarageRating would be much easier
await ctx.db
.query("posts").filter(q => q.gte(q.field("avarageRating"), 3))
...