Closed klom303 closed 4 years ago
How is your number being stored? ETcd uses the byte sort order to compare the values. So the string "100" is less than "7", since the byte for the character 1 comes before 7.
If this is the problem, I'd suggest storing your numbers encoded as big endian integers to make sure the sort is correct.
function store(myValue) {
const buf = Buffer.alloc(4);
buf.writeUInt32BE(myValue);
return client.put(key).value(buf);
}
async function read() {
const buf = await client.get(key).buffer();
return buf === null ? null : buf.readUint32BE();
}
etcd3 Version: 0.2.13 etcd Version: 3.3.12 nodejs Version: 10.15.3 OS: Ubuntu 18.04
In a transaction,
if()
support compare condition. In my case, I want to compareValue
to a number, but the result is wrong.response
It seems before the compare step, the number parameter was converted to a string. Is this the correct usage ?