Rethinkdb .net更新值
Rethinkdb .net update value
我正在考虑使用 C# RethinkDB.Driver 库更新 RethinkDB 中的存储值,但我只是没有做对。
我可以通过获取结果、更改该对象然后单独调用以使用该对象进行更新来实现更新。当像这样多次调用记录进行更新时,当应用程序正在处理记录时,值会在其他地方更新。
TestingObject record = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Run(_conn);
record.fieldNameIntValue = record.fieldNameIntValue + 1;
var result = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Update(record).Run(_conn);
我一直在尝试这些方法:
var result = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Update(row => row["fieldNameIntValue"].Add(1)).Run(_conn);
但结果错误 Inserted value must be an OBJECT (got NUMBER):101
这表明这只是传回字段值而不是更新对象。
理想情况下,我想一次更新多个列,欢迎任何建议:)
这是一个适用于 ReQL 数据浏览器的示例。您可以根据需要在更新之前链接尽可能多的过滤器。我认为这将转化为 C# 驱动程序,但我对此没有任何经验。
r.db('database').table('tablename').update({clicks: r.row("clicks").add(1)}).run().then(function(result){ ...
谢谢 T Resudek 并且更清晰的头脑帮助强调了 map 计算到 属性.
的必要性
查看 javadocs for update it has HashMap method which I followed with the c# library 并且有效。
var result = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Update(row => r.HashMap("fieldNameIntValue",row["fieldNameIntValue"].Add(1))).Run(_conn);
我很想知道这是正确的方法还是更好的方法。
我正在考虑使用 C# RethinkDB.Driver 库更新 RethinkDB 中的存储值,但我只是没有做对。
我可以通过获取结果、更改该对象然后单独调用以使用该对象进行更新来实现更新。当像这样多次调用记录进行更新时,当应用程序正在处理记录时,值会在其他地方更新。
TestingObject record = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Run(_conn);
record.fieldNameIntValue = record.fieldNameIntValue + 1;
var result = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Update(record).Run(_conn);
我一直在尝试这些方法:
var result = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Update(row => row["fieldNameIntValue"].Add(1)).Run(_conn);
但结果错误 Inserted value must be an OBJECT (got NUMBER):101
这表明这只是传回字段值而不是更新对象。
理想情况下,我想一次更新多个列,欢迎任何建议:)
这是一个适用于 ReQL 数据浏览器的示例。您可以根据需要在更新之前链接尽可能多的过滤器。我认为这将转化为 C# 驱动程序,但我对此没有任何经验。
r.db('database').table('tablename').update({clicks: r.row("clicks").add(1)}).run().then(function(result){ ...
谢谢 T Resudek
查看 javadocs for update it has HashMap method which I followed with the c# library 并且有效。
var result = r.Db("test").Table("learning").Get("c8c54346-e35f-4025-8641-7117f12ebc5b").Update(row => r.HashMap("fieldNameIntValue",row["fieldNameIntValue"].Add(1))).Run(_conn);
我很想知道这是正确的方法还是更好的方法。