noob saibot
noob saibot•3w ago

Is the bound key required when reading an aggregate count with namespace?

First, I have defined an aggregation like so:
app.use(aggregate, { name: "partners_payments" });
app.use(aggregate, { name: "partners_payments" });
Second, in the code, this is how I connect it with the table payments
export const partnerPaymentsAggregate = new TableAggregate<{
Key: number;
Namespace: Id<"partners"> | undefined;
DataModel: DataModel;
TableName: "payments";
}>(components.partners_payments, {
namespace: doc => doc.partner_id,
sortKey: doc => doc._creationTime,
});
export const partnerPaymentsAggregate = new TableAggregate<{
Key: number;
Namespace: Id<"partners"> | undefined;
DataModel: DataModel;
TableName: "payments";
}>(components.partners_payments, {
namespace: doc => doc.partner_id,
sortKey: doc => doc._creationTime,
});
And finally, jere I'm attempting to read the count from it:
const count = await partnerPaymentsAggregate.count(ctx, {
namespace: partner_id,
});
const count = await partnerPaymentsAggregate.count(ctx, {
namespace: partner_id,
});
But typescript screams:
Property 'bounds' is missing in type '{ namespace: Id<"partners">; }' but required in type '{ bounds: Bounds<number, Id<"payments">>; }'.
Property 'bounds' is missing in type '{ namespace: Id<"partners">; }' but required in type '{ bounds: Bounds<number, Id<"payments">>; }'.
Is the bound property mandatory here? In my particular scenarion, I would like to get the total count of records and not just a part
6 Replies
Convex Bot
Convex Bot•3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
lee
lee•3w ago
good feature request. as a workaround until it's supported, i think you can do bounds: {} and it will get you everything
noob saibot
noob saibotOP•3w ago
I just added bounds: {}. But it requires at least prefix (lower and upper are optional). What value should I give to "prefix"?
lee
lee•3w ago
hmm it shouldn't require prefix. can you share the error message? it works for me with bounds: {}
noob saibot
noob saibotOP•3w ago
Apologies, it is not required (this was an unrelated eslint error...)
lee
lee•3w ago
looks like there's already a feature request i hadn't noticed before 🙈 https://github.com/get-convex/aggregate/issues/22

Did you find this page helpful?