
import { DoesExistItem } from '../../../@utility/data-structures/database'

import { storeTable } from '../variables'
import { createItemStore } from './create-item-store'

const doesExistItem: DoesExistItem = doesExistItemFunction

async function doesExistItemFunction (storeId: string, itemId: string): Promise<boolean[]> {
  if (!storeTable[storeId]) {
    await createItemStore(storeId)
  }

  const item = await storeTable[storeId].getItem(itemId)

  return [item ? true : false]
}

export {
  doesExistItem
}