2naive / mysql2-cache

MySQL2 upgrade: cache mysql queries, easy shortcuts, logging and debugging.
1 stars 0 forks source link

Callback with q method #1

Open polina-collab opened 1 month ago

polina-collab commented 1 month ago

Hi! Thanks for a great lib! Is it possible to use .q method with callback instead of promise? And can we use createPool and then call .q method?

2naive commented 1 month ago

Hi! Thanks for a great lib! Is it possible to use .q method with callback instead of promise? And can we use createPool and then call .q method?

Hi @polina-collab,

Thanks for your kind words! I'm glad you find the library helpful.

  1. The .q method in mysql2-cache is designed to work with promises, but you can still use it in a callback-style pattern by converting the promise into a callback manually by using Node.js's util.callbackify() utility to convert the promise-based function into a callback-based one.

  2. Yes you may, but .connect method already utilizes pooling, so you don't need to. But thanks for pointing it out that it's not mentioned in readme.

Hope that helps