import db from './dexie'
const { vodFav } = db

export default {
  async get(id) {
    return await vodFav.get(id)
  },
  async list(page, limit = 20) {
    const offset = (page - 1) * limit
    const count = await vodFav.where({status: 1}).count()
    const pageCount = Math.ceil(count / limit)
    const list = await vodFav.orderBy('time').reverse().filter((record) => record.status == 1).offset(offset).limit(limit).primaryKeys()
    return {list: list, count: count, pageCount: pageCount}
  },
  async update(id, data) {
    return await vodFav.update(id, data)
  },
  async delete(id, data) {
    return await vodFav.delete(id)
  },
  async remove(ids) {
    return await vodFav.bulkDelete(ids)
  },
  async put(data) {
    return await vodFav.put(data)
  }
}
