const knex = require('../../knex.js')

const Media = module.exports = {
  posted_by: ({user_id}) =>
    knex('users').where('id', user_id).then(([user]) => user),
  myReaction: ({id}, _, {me}) =>
    knex('reactions').where({user_id: me.id, media_id: id})
                     .limit('1')
                     .then(([row]) => row)
}

const knex = require('../../knex.js')

const Media = module.exports = {
  posted_by: ({user_id}) =>
    knex('users').where('id', user_id).then(([user]) => user),
  myReaction: ({id}, _, {me}) =>
    !me
      ? null
      : knex('reactions').where({user_id: me.id, media_id: id})
                         .limit('1')
                         .then(([row]) => row)
}

Return null for reaction if user isn't connected
Return null for reaction if user isn't connected
