How to use the queryBuilder function from knex

Find comprehensive JavaScript knex.queryBuilder code examples handpicked from public code repositorys.

198
199
200
201
202
203
204
205
206
207
// const createMedia = {
//     media:      request.body.recordObject.media,
//     sortID:     newSortID
//   };

db.queryBuilder()
  .from(tableName)
  .max("sortID")
  .first() // * Add this to get an object. -- 05/06/2021 MF
  .then((maxSortID) => {
fork icon0
star icon0
watch icon0

46
47
48
49
50
51
52
53
54
55
/**
 * Get error count of exercise
 *
 */
const getExercisesErrorCount = async ({ courseId }) => (
  knex.queryBuilder()
    .select(knex.raw('eec.exercise_id, eec.guide_id, eec.course_id, eec.user_id, ex.name, sum(error_count)::integer as count'))
    .from('exercise_errors_count as eec')
    .innerJoin('exercises as ex', function innerJoinFn() {
      this.on('eec.exercise_id', 'ex.exercise_id');
fork icon0
star icon0
watch icon3

+ 7 other calls in file