esselitowE
Convex Community3w ago
1 reply
esselitow

triggers.register("tableName", aggregate.trigger()) fails

Following the docs and example: https://github.com/get-convex/aggregate/blob/HEAD/example/convex/photos.ts

I am creating a aggreagate:
export const aggregateOrders = new TableAggregate<{
  Key: [number, boolean, string, string];
  DataModel: DataModel;
  TableName: "orders";
}>(components.orders, {
  sortKey: (doc) => [
    doc.status,
    doc.markedAsDone,
    doc.orderPartnerId ?? "",
    doc.orderTypeId ?? "",
  ],
});


And I try to create a trigger that handles this aggregate for me:
const triggers = new Triggers<DataModel>();

triggers.register("orders", aggregateOrders.trigger());

export const mutationWithTriggers = customMutation(
  rawMutation,
  customCtx(triggers.wrapDB)
);


But now I get:
✖ Error: Unable to start push to https://<redacted>.convex.cloud
✖ Error fetching POST  https://<redacted>.convex.cloud/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
    error:
Failed to analyze actions.js: Uncaught TypeError: x is not a function


I know it complains about actions.js but that is just the first file in my convex folder. if I just comment out the line
triggers.register("orders", aggregateOrders.trigger());

everything starts working again
GitHub
Component for aggregating counts and sums of Convex documents - get-convex/aggregate
aggregate/example/convex/photos.ts at 37cbcf99846b09ff3322af4abb4e7...
Was this page helpful?