插入数据时怎样判断表中是否已存在相同名称?
我以为这样return可以停止程序向下运行,但是没起作用,有人说是异步 问题,但不懂怎么改,
请教一下怎么改才能判断表中有存在一样名字的就停下运行?谢谢
create: function () {
if (!this.data.titleshow) {
wx.showToast({
title: '请填写标题~',
icon: 'none'
});
return;
}
db.collection(kinds).where({
title:this.data.titleshow
}).get().then(
res=>{
if(res.data.length>0)
{
wx.showToast({
title: '已存在',
})
return;
}
}
)
wx.showLoading({
title: '正在创建……',
mask: true
});
}
