Bookshelf has no inbuilt method for performing such a query but it actually ended up being rather simple.