cant disable cache
hi, i'm having some problems using sqlagent with pg in a koa project, it all works great but the queries are getting cached and i don't want them to, is there a way i can disable the caching?
Hi @driff, what cache do you mean? The module caches info about connection string and some meta info for sorting.
Thank you!
hi @petersirka, i'm having the following problem, whenever i do a query, that data is cached for some reason, when i change the value of the data and call the same query, sqlagent brings me the cached query instead of the data in the DB, could it be because with koa i'm using the same instance of sqlagent everywhere?
for example:
ctx.sql.select('user', 'user_table').make(b=>{
b.where('id', id);
b.limit(1);
b.fields('id', 'password', 'full_name', 'email')
});
ctx.sql.exec((err, r)=>{
resolve(r.user);
});
now say the password changed, when i call that query again it brings me the old password because it's cached.
Hi @driff You should use it like this:
var Agent = require('sqlagent/pg').connect('connetion-string-to-postgresql');
app.context.Agent = Agent;
Then in the route handler:
var sql = ctx.Agent(); // this returns new instance of the Agent
sql.select('user', 'user_table').make...
sql.exec((err, r)=>{ ...
@driff try to use @molda solution, the module has had a bad info in readme.
Thanks!! it is working now!