Skip to content
Snippets Groups Projects
Commit d1d98221 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add resetSql function

parent 2c771a44
No related branches found
No related tags found
1 merge request!116Release v1.0.0
Pipeline #
......@@ -33,14 +33,17 @@ app.use(cors());
app.use(methodOverride());
// Middleware tha adds the squel object to req
app.use((req, res, next) => {
req.sql = squel.select();
// HACK to know wich table we are using
req.sql.oldFrom = req.sql.from;
req.sql.from = (name, alias = null) => {
req.sql.oldFrom(name, alias || null);
req.sql.tableFrom = name;
return req.sql;
req.resetSql = () => {
req.sql = squel.select();
// HACK to know wich table we are using
req.sql.oldFrom = req.sql.from;
req.sql.from = (name, alias = null) => {
req.sql.oldFrom(name, alias || null);
req.sql.tableFrom = name;
return req.sql;
};
};
req.resetSql();
next();
});
app.use(passport.initialize());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment