gpt4 book ai didi

javascript - 书架.js : Avoid fetch call after call to save (update)

转载 作者:行者123 更新时间:2023-12-04 09:42:37 26 4
gpt4 key购买 nike

我们在 MySQL 中使用 bookshelf.js。

我们有一个表:联系方式 ( id, name, email_Id, updated_Contact_At )

书架查询:

new Contact({id: 1}).save(
{name: 'Jhon Snow', email_Id: 'jhonsnow42@gmail.com', birthdate:'1998-10-21'},
{patch: true, default: false, require: true, method: 'update'}
);

这转化为:
Update Contact set name = "Jhon Snow", 
email_Id = 'jhonsnow1212@gmail.com',
birthdate = '1998-10-21',
updated_Contact_At = 020-06-08T09:18:10.513Z
where id = 1;

执行上述查询书架后,获取相同的记录:
select Contact.* from Contact where Contact.id = 1 limit 1

bookshelf.js 中是否有任何方法可以在更新记录后停止 fetch 调用?

最佳答案

您可以在更新记录时使用 autoRefresh = false

new Contact({id: 1}).save(
{name: 'Jhon Snow', email_Id: 'jhonsnow42@gmail.com', birthdate:'1998-10-21'},
{patch: true, default: false, require: true, method: 'update', autoRefresh : false}
);

使用 Bookshelf.js 版本:^1.2.0

关于javascript - 书架.js : Avoid fetch call after call to save (update),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62261020/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com