使用云后台设置了”订单状态“字段为枚举类型,并且设置了默认值,云函数使用"models.<create>"方法创建一条数据的时候没有传入该属性的值,即status的值,在数据创建成功后,在数据库中查询该条数据并没有status属性。
云函数内容
const { OPENID } = cloud.getWXContext()
const {
username,
userPhone,
bookDate,
bookTime,
bookTimestamp,
workId,
workTitle,
workCover,
workPrice,
storeId,
storeName,
storeAddress,
} = event
const bookDateTime = `${bookDate} ${bookTime}`
// 创建订单
const { data } = await models.orders.create({
data: {
_openid: OPENID,
username: username,
book_timestamp: bookTimestamp,
book_date_time: bookDateTime,
phone: userPhone,
work_id: workId,
work_name: workTitle,
work_cover: workCover,
work_price: workPrice,
store_id: storeId,
store_name: storeName,
store_address: storeAddress,
}
})
为"status"字段设置默认值
插入数据库的结果