You are browsing as a guest. Sign up (or log in) to start making projects!

8h 13m 21s logged

Devlog 12

So I added the payments page and fixed a lot of bugs.
I have only slept 6 hours (3:30 prev night and around 2 at evening) for the past 35+ hours. I am only one coffee deep rn.

So lets talk about the bugs and all in a little detail.

  • The latest bug I was facing was, I am using an paginate plugin in the backend mongoose aggregate paginate v2 so it doesn’t allow complex queries and stuff and there is a option countQuery which is to be set to the same aggregate used in aggregatePaginate, let me show you with the code

const payments = await Payment.aggregatePaginate(paymentAggregate, {
  page,
  limit,
  countQuery: Payment.aggregate(pipeline)
});
  • I had no idea this thing existed because the docs are not well properly documented for the plugin.

  • First of all I was thinking why isn’t the search working my code is completely right, then I came to the conclusion with the help of AI also debugging with me ofc that aggregatePaginate is the problem then I found out that i can use countQuery.

  • Also before this, the search in products table wasn’t working, as I am using a template underneath so I checked the implementation, nuqs package is used for searchParams and for the table I’m using Tanstack Table which also had search filter so I had to get the value from the tanstack table search filter instead of from nuqs which also took me a while to debug.

  • Then before that bug, I had a bug where the table weren’t getting updated if actions were performed on the same page without refresh like delete or in client page create or update, so the issue was I was invalidating queris serverSide instead I had to invalidate clientSide.

  • Also some minor backend things, invoice get route filters had email / name differently i combined them to one search.

  • The index in products on sku + businessId was considering null as one so I added

{
  unique: true,
  partialFilterExpression: {
    sku: { $type: 'string' },
  },
}
  • Also in frontend, the fetch wrappers I had were converting all the body into json, so i fixed that If formData is present send it as formData not json.

  • Also I’m uploading files and sending the request via server actions in Nextjs, there was a default limit of 1mb so I added config for it in next.config.ts, it is a experimental config though.

I think that is It, Just couple more hours of the project left then I will ship it.

0
2

Comments 0

No comments yet. Be the first!