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

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

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