我有一个GCP BigQuery示例设置,我想设置我的网页写入数据到一个特定的数据/集合。我已经成功地建立了wix.com托管网站和GCP之间的连接。我已经证明了在wix.com GUI中手动编辑记录。现在我想通过代码来完成这一点。下面的代码旨在做到这一点。代码执行w/out错误,但是数据实际上并没有被写入GCP BigQuery表。我假设我错过了提交记录更改的最后一步,但我只是不确定那是什么。任何帮助都非常感谢,我意识到我是JS新手,所以请耐心一点:-)。
itemID是调用函数时传递的项ID。
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
1条答案
按热度按时间bkhjykvo1#
本质上,我遇到了一个记录锁定问题,BigQuery流缓冲区阻止了更新。我的解决方案是使用APPEND来存储每次更改的数据,然后在我的网站上显示数据,并显示最大记录。