2020-01-21 07:05:55 +00:00
|
|
|
const knex = require('../db');
|
2020-01-18 23:49:35 +00:00
|
|
|
|
2020-01-23 22:46:49 +00:00
|
|
|
const roomSelect = [
|
|
|
|
'id', 'name', 'description', 'language',
|
2020-01-22 00:01:35 +00:00
|
|
|
]
|
|
|
|
|
2020-01-18 23:49:35 +00:00
|
|
|
const findPublicRooms = async () => {
|
|
|
|
return await knex('room')
|
|
|
|
.where('private', false)
|
2020-01-23 22:46:49 +00:00
|
|
|
.select(roomSelect);
|
2020-01-18 23:49:35 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 00:01:35 +00:00
|
|
|
const findRoomById = async (roomId) => {
|
2020-01-23 22:46:49 +00:00
|
|
|
const results = await knex
|
2020-01-22 00:01:35 +00:00
|
|
|
.from('room')
|
2020-01-23 22:46:49 +00:00
|
|
|
.select(roomSelect)
|
|
|
|
.where('room.id', roomId)
|
|
|
|
|
|
|
|
return results[0]
|
2020-01-22 00:01:35 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 23:49:35 +00:00
|
|
|
module.exports = {
|
2020-01-22 00:01:35 +00:00
|
|
|
findPublicRooms,
|
|
|
|
findRoomById
|
2020-01-18 23:49:35 +00:00
|
|
|
}
|