我有一个GCP BigQuery实例设置,我想设置我的网页写数据到特定的数据/集合。我已经成功建立了wix.com托管网站与GCP的连接。我已经证明了在wix.com GUI中手动编辑记录。现在我想通过代码来完成这一点。下面的代码就是为了做到这一点。代码执行w/out错误,但数据实际上并没有写入GCP BigQuery表。我假设我错过了提交记录更改的最后一步,但我只是不确定那是什么。任何帮助都是非常感激的,我意识到我是一个新手,当谈到JS时,请耐心一点:-)。
itemID是调用函数时传递的项ID。我正在获取itemID与代码
let item = $w('#dataGCPOperational').getCurrentItem();
saveData(item._id);
export function saveData(itemID){
let userEmail = currentMember.getMember().then((member) => {
return member.loginEmail;
})
let instagramHandle = $w('#inputInstagram').value
console.log("instagramHandle " + instagramHandle)
let market = $w('#dropdownMarket').value
console.log("market " + market)
//let optIn2023 = $w('#checkbox2023OptIn').value
let howManyYrs = $w('#inputYearsParticipated').value
console.log("howManyYrs " + howManyYrs)
let howManySixteen = $w('#inputYearsCompleted16').value
console.log("howManySixteen " + howManySixteen)
let participatedBefore = $w('#checkboxParticipatedBefore').value
console.log("participatedBefore " + participatedBefore)
let sixteenBefore = $w('#checkboxCompleted16Before').value
console.log("sixteenBefore " + sixteenBefore)
let exclProgressBoard = $w('#checkboxExcludeFromLeaderboard').value
console.log("exclProgressBoard " + exclProgressBoard)
wixData.get("gcpOperationalDB/tblSTMParticipantData", itemID)
.then(item => {
item.email = userEmail
item.instagram = instagramHandle;
item.market = market
item.numYearsParticipated = howManyYrs
item.numYearsSixteen = howManySixteen
item.participatedBefore = participatedBefore
item.recordedSixteen = sixteenBefore
item.excludeFromLeaderboard = exclProgressBoard
})
return $w('#dataGCPOperational').save()
.then(() => {
console.log("Item updated successfully");
})
.catch((err) => {
console.log("Failed to update item: " + err);
});
}
我希望这些变量的值被写入$w('#dataGCPOperational')
引用的GCP表中的适当字段。
let instagramHandle = $w('#inputInstagram').value
let market = $w('#dropdownMarket').value
let howManyYrs = $w('#inputYearsParticipated').value
let howManySixteen = $w('#inputYearsCompleted16').value
let participatedBefore = $w('#checkboxParticipatedBefore').value
let sixteenBefore = $w('#checkboxCompleted16Before').value
let exclProgressBoard = $w('#checkboxExcludeFromLeaderboard').value
基本上,我遇到了BigQuery流缓冲区阻止更新的记录锁定问题。我的解决方法/解决方案是使用APPEND来存储每次更改的数据,然后在我的网站上显示显示最大记录的视图的数据。