我想把data数据上传到云数据库
错误:VM1378:2 (in promise) MiniProgramError
errCode: -501007 invalid parameters | errMsg: [InvalidParameter] Check request parameter fail. Please check your request, but if the problem cannot be solved, contact us.
Error: errCode: -501007 invalid parameters | errMsg: [InvalidParameter] Check request parameter fail. Please check your request, but if the problem cannot be solved, contact us.
playlist.js:
const db = wx.cloud.database()
Page({
data: {
playlist:[{"_id":"1""playCount":1.4641238e+06,"highQuality":false,"type":0.0,"canDislike":true,"name":"天气转热了,适合听点凉爽的歌。"},
{"_id":"08560c9e5d042a5c0174f1da7aa357aa","highQuality":false,"playCount":622822.6,"id":2.740107647e+09,"name":"「时空潜行","type":0.0},
{"_id":"08560c9e5d042a5c0174f1de21c7e79e","id":2.828842343e+09,"type":0.0,"name":"粤语","canDislike":true},
{"_id":"08560c9e5d042a5d0174f1e67d1bb16f","playCount":7.719329e+06,"highQuality":false,"id":9.17794768e+08,"type":0.0,"name":"翻唱简史","canDislike":true}
]
},
playlisttodb()
{
const len=this.data.playlist.length
for (let i = 0; i < len; i++) {
let that=this
let arr=this.data.playlist[i]
that.setData({
arr:arr,
})
db.collection('playlistdb').add({
data:
{
arr,
createTime: db.serverDate(),
}
})
}
},
onLoad: function (options) {
},
onReady: function () {
}
}
playlist.wxml
<view>
<button bind:tap="playlisttodb">歌单转入数据库</button>
</view>
试试吧 async playlisttodb() { const len=this.data.playlist.length for (let i = 0; i < len; i++) { let that=this let arr=this.data.playlist[i] that.setData({ arr:arr, }) await db.collection('playlistdb').add({ data: { arr, createTime: db.serverDate(), } }) } },