如何在Wix Corvid的主字段中插入值

问题描述 投票:0回答:1

我在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重复

您能找到解决方案吗?

谢谢

wixcode
1个回答
0
投票

您需要在dropdowns中使用#myElementID

类似于SQL中的this

if not exists (select * from Delegates d where d.FromYr = @FromYr and d.MemNo = @MemNo) INSERT INTO Delegates ([MemNo],[FromYr],[ToYr]) values(@MemNo, @FromYr,@ToYr)

其他参考this

© www.soinside.com 2019 - 2024. All rights reserved.