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

export default {
  async get(id) {
    return await vodHistory.get(id)
  },
  async list(page, limit = 20) {
    const offset = (page - 1) * limit
    const count = await vodHistory.count()
    const pageCount = Math.ceil(count / limit)
    const list = await vodHistory.orderBy('time').reverse().offset(offset).limit(limit).primaryKeys()
    return {list: list, count: count, pageCount: pageCount}
  },
  async put(data) {
    return await vodHistory.put(data)
  },
  async remove(ids) {
    return await vodHistory.bulkDelete(ids)
  },
  async clear() {
    return await vodHistory.clear()
  }
}
