const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

exports.main = async (event) => {
  const db = cloud.database();
  const _ = db.command
  try {
    const {
      data: users
    } = await db.collection('user').get()
    return {
      success: true,
      data: users
    }
  } catch (err) {
    return {
      success: false,
      msg: err.message
    }
  }
}