我在Corvid数据库中有事件表,对于每个新事件,它都有Event_Id列,而表单中用户没有要求它。
我使用以下代码来获取行数并从现在有效的行中生成ID:
let count = 0;
$w("#collection").onReady( () => {
count = $w("#collection").getTotalCount(); // 23
count++;
} );
$w('#btnSub').onClick( ()=>{
const newRequest = {
eventid:('event_'+count),
title: $w('#title').value
}
wixData.insert('event_instance', newRequest);
但是当我从集合中删除其中一行时,这可能导致事件ID重复
您能找到解决方案吗?
谢谢