微信小程序云数据库可以根据查询到的内容后再决定更新或者不更新吗?

小程序 文章 2021-12-21 09:00 306 0 全屏看文

AI助手支持GPT4.0

微信小程序云数据库可以根据查询到的内容后再决定更新或者不更新吗?Can the WeChat applet cloud database be updated or not updated based on the content queried?

微信小程序云数据库可以根据查询到的内容后再决定更新或者不更新吗?

各路大神求教:

云数据库想要更新一条信息,但是不确保在这之前有没有其他用户已经操作,所以先查询数据库状态,然后根据返回的信息决定是否更新信息。

类似于抢购,查询和更新可以同时操作吗?必须要先等一个执行完了,在调用一次执行吗

Various gods ask for advice: cloud database wants to update a piece of information, but it does not ensure whether other users have operated before, so first query the database status, and then decide whether to update the information according to the returned information. Similar to rush buying, can query and update be operated at the same time? Do you have to wait for an execution to complete before calling an execution

回答:

xplee:

等你查询完再去更新,说不定其他人已经更新了一次,你再更新就没意思了,除非加上更新条件,条件中包含那个要更新的字段的值。

Larry:

把查询条件写在where里,不符合条件的话就查询不到记录

db.collection('...')  .where({    ...  })  .update({    data: ...  })

-EOF-

AI助手支持GPT4.0