How to use the withSchema function from knex

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

97
98
99
100
101
102
103
104
105
106
107


//getting cinemaid by cinema name
router.get('/getcinemaidbyname/:cinemaname', async (req, res) => {
  try {
    console.log('sending cinema id by cinema name');
    const result = await knex.withSchema('bookmyshow').table('cinemas').where('name', req.params.cinemaname);
    res.json({ result: result[0].id });
  }
  catch (error) {
    console.log(error);
fork icon0
star icon0
watch icon0

+ 7 other calls in file

235
236
237
238
239
240
241
242
243
244
245
//returning role to the frontend
router.get('/getrole', async (req, res) => {
  try {
    let temp = req.headers.authorization.split(' ');
    const token = temp[1];
    record = await knex.withSchema('bookmyshow').table('users').where('jwt', token);


    console.log('record is', record[0]);
    console.log(record[0].role);

fork icon0
star icon0
watch icon0

+ 16 other calls in file

142
143
144
145
146
147
148
149
150
151
152
153
154






// router.get('/getactivemovies', async (req, res) => {
//   try {
//     const result = await knex.withSchema('cinemabackend').table('moviesdetails').where('isactive', true);
//     res.json(result);
//   }
//   catch (error) {
//     console.log('catch' + error);
fork icon0
star icon0
watch icon0

+ 7 other calls in file