export const countByOwnerAndMonth = query({
args: {
org: v.optional(v.string()),
month: v.optional(v.string()),
},
handler: async (ctx, args) => {
const owner = await ensureOwner(ctx, args.org);
const start = dayjs(args.month).startOf("month").unix() * 1000;
const end = dayjs(args.month).endOf("month").unix() * 1000;
return await incomingAggregate.count(ctx, {
namespace: owner,
bounds: {
lower: { key: start, inclusive: true },
upper: { key: end, inclusive: true },
},
});
},
});
export const countByOwnerAndMonth = query({
args: {
org: v.optional(v.string()),
month: v.optional(v.string()),
},
handler: async (ctx, args) => {
const owner = await ensureOwner(ctx, args.org);
const start = dayjs(args.month).startOf("month").unix() * 1000;
const end = dayjs(args.month).endOf("month").unix() * 1000;
return await incomingAggregate.count(ctx, {
namespace: owner,
bounds: {
lower: { key: start, inclusive: true },
upper: { key: end, inclusive: true },
},
});
},
});