title: Manually Lock Table in Knex
body: <p>I have one table, when a new row is added to it, all existing rows need to be updated. Essentially, before one "insert" is finished, I don't want to allow another "insert" to take place. </p>
  
  <p>So I guess normal row level lock or read lock is not enough and want to directly lock the tables during the transaction. </p>
  
  <p>Is there a way to manually lock tables (in ACCESS EXCLUSIVE mode) in Knex? </p>
  
  <p>My guess is that this will involve:</p>
  
  <ol>
  <li><p>running raw sqls (lock and unlock) and  make sure the same</p></li>
  <li><p>connection is used for the transaction.</p></li>
  </ol>
  
  <p>Is there a way to do that? or I there are better solution to my problem. </p>
  
  <p>p.s. another approach I'm exploring is to use a job queue and let a single worker to insert records (using a raw sql connection). But I was told this will not work in a multiple node scenario.</p>