提交 7eaad3b2 编写于 作者: DCloud_JSON's avatar DCloud_JSON

修改 unicloud-test表相关操作的表字段名称

上级 70a8c62f
......@@ -37,9 +37,8 @@
uniCloud.callFunction({
name: 'add',
data: {
name: 'DCloud',
subType: 'uniCloud',
createTime: Date.now()
product: 'uniCloud',
create_time: Date.now()
}
}).then((res) => {
uni.hideLoading()
......@@ -86,9 +85,8 @@
uniCloud.callFunction({
name: 'update',
data: {
name: 'DCloud',
subType: 'html 5+',
createTime: Date.now()
product: 'uni-app',
create_time: Date.now()
}
}).then((res) => {
uni.hideLoading()
......
......@@ -50,9 +50,8 @@
title: '处理中...'
})
cloudObjectDemo.add({
name: 'DCloud',
subType: 'uniCloud',
createTime: Date.now()
product: 'uniCloud',
create_time: Date.now()
}).then((res) => {
console.log(res)
uni.hideLoading()
......@@ -94,9 +93,8 @@
title: '处理中...'
})
cloudObjectDemo.update({
name: 'DCloud',
subType: 'html 5+',
createTime: Date.now()
product: 'uni-app',
create_time: Date.now()
}).then((res) => {
uni.hideLoading()
uni.showModal({
......
const db = uniCloud.database();
const testCollection = db.collection('unicloud-test')
module.exports = {
async add({ name, subType, createTime }) {
let res = await testCollection.add({ name, subType, createTime })
async add({product, create_time }) {
let res = await testCollection.add({product, create_time })
return res
},
async remove() {
......@@ -26,7 +26,7 @@ module.exports = {
}
}
},
async update({name,subType,createTime}) {
async update({product,create_time}) {
const docList = await testCollection.limit(1).get();
if (!docList.data || docList.data.length === 0) {
return {
......@@ -34,11 +34,11 @@ module.exports = {
msg: '集合unicloud-test内没有数据'
}
}
const res = await testCollection.doc(docList.data[0]._id).update({name,subType,createTime});
const res = await testCollection.doc(docList.data[0]._id).update({product,create_time});
if (res.updated === 1) {
let result = Object.assign({}, {
_id: docList.data[0]._id
}, {name,subType,createTime})
}, {product,create_time})
return {
status: 0,
msg: `集合第一条数据由${JSON.stringify(docList.data[0])}修改为${JSON.stringify(result)}`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册