<template>
  <view class="container p-3">
    <u-button type="primary" class="mb-3" @click="add">add</u-button>
    <u-button type="primary" class="mb-3" @click="findOne">findOne</u-button>
    <u-button type="primary" class="mb-3" @click="find">find</u-button>
    <u-button type="primary" class="mb-3" @click="update">更新update</u-button>
    <u-button type="primary" class="mb-3" @click="remove">删除remove</u-button>
    <u-button type="primary" class="mb-3" @click="createIndex">创建索引和查询</u-button>
  </view>
</template>

<script>
export default {
  created() {
    // this.getProjects(this.$moment().startOf('day').valueOf(), this.$moment().endOf('day').valueOf());
  },

  methods: {
    async getProjects(startTime, endTime) {
      const data = await this.$t.$q.getProjects(startTime, endTime);
      console.log('data: ', data);
    },

    add() {
      this.$db.create('projects', { id: '124', sex: ' man' });
    },

    async findOne() {
      const data = await this.$db.findOne('projects', '124');
      console.log(data);
    },

    async find() {
      const data = await this.$db.find('projects');
      console.log(data);
    },

    async update() {
      const data = await this.$db.update('projects', { id: '125', sex: 'woman' });
      console.log('update data: ', data);
    },

    async remove() {
      const data = await this.$db.remove('projects', '123');
      console.log('update data: ', data);
    },

    // TODO:
    async createIndex() {
      // const data = await this.$db.createIndex('projects', 'sex', 'woman');
      console.log('update data: ');
    },
  },
};
</script>
