首页 > 解决方案 > 使用带有真值 if 语句的 etcd 事务

问题描述

在 JavaScript 中,我试图etcd在 1 个事务中进行多个密钥更新。我已经过滤了我想要在事务之前更新的键值对,所以基本上我没有任何比较要做。我想像这样使用它:

const client = new Etcd3({ hosts: connectionString });

...

await client.if(true)
                .then(
                    client.put(entry1).value(JSON.stringify(account1, null, 4));
                    client.put(entry2).value(JSON.stringify(account2, null, 4));
                    client.put(entry3).value(JSON.stringify(account3, null, 4));
                    client.put(entry4).value(JSON.stringify(account4, null, 4));
                )
                .else();

有什么我可以代替true它以同样的方式起作用的吗?

标签: javascripttransactionsetcd

解决方案


推荐阅读