const db = require('../../db');

const checkSession = async (token) => {
  try {
    const [sessionIsValid] = await db('users')
      .select('id')
      .whereNull('deletedAt')
      .andWhere('sessionToken', '=', token);

    return !!sessionIsValid
  } catch (e) {
    return 'error' + e
  }
}

module.exports = checkSession;
