How to add nolock condition in the bookshelf or knex nodejs before fetch

213 Views Asked by At

I am using a bookshelf and wanted to add the default value as WITH(NO LOCK)

Update: is it possible to achieve this using knex as I have that library installed in my code?

User.forge()
        .fetchAll({withRelated: ['role']})
        .then(function(result) {
            if (result === null)
                res.json({data: []});
            else
                res.json({data: result.toJSON()});
        })
        .catch(err => {
            res.json({error: err.message});
        });
  • I tried adding User.forge('WITH(NO LOCK)') but it is not working.
  • there is an option to add default values in the model but I don't want to touch the model as it is used in another place in my code so I am looking to add no lock only at one API call.
0

There are 0 best solutions below