2020-01-21 07:36:52 +00:00
|
|
|
const knex = require('../db');
|
2020-01-22 01:02:54 +00:00
|
|
|
const joinUserSelect = [
|
|
|
|
'content', 'username', 'admin'
|
|
|
|
]
|
2020-01-21 07:36:52 +00:00
|
|
|
|
|
|
|
const findMessageByRoom = async (roomId) => {
|
2020-01-22 01:02:54 +00:00
|
|
|
return await knex
|
|
|
|
.from('message')
|
|
|
|
.where({'message.room': roomId})
|
|
|
|
.select(joinUserSelect)
|
|
|
|
.join('user', function() {
|
|
|
|
this.on('message.user', '=', 'user.id')
|
|
|
|
})
|
|
|
|
// .toSQL();
|
2020-01-21 07:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
findMessageByRoom
|
|
|
|
}
|