我有一个关于ravenDb的任务,我已经编写了用于 Select 、排序、过滤等的查询.但是我想不出如何简单地将新文档添加到名为"Employees"的集合中,或者更新文档"Employees/8-A"中来自"Employees"的值.

我已经使用以下链接浏览了文档:

https://ravendb.net/docs/article-page/5.4/csharp/client-api/operations/patching/set-based. https://ravendb.net/docs/article-page/5.4/csharp/client-api/operations/patching/single-document.

我甚至谷歌了一下,发现了这个帖子;Updating documents in RavenDB篇,但有一篇链接的文章被删除了.

但这只是JS代码.在raven db Studio的查询工具中有没有可以运行的语法?

推荐答案

为了管理来自Session的更新, 请看以下演示:

Adding/creating a new document:
https://demo.ravendb.net/demos/csharp/basics/create-document
Load and edit document:
https://demo.ravendb.net/demos/csharp/basics/load-and-edit-document


For updating a field with Patching, from all docs, see the inner RQL for example here:
https://ravendb.net/docs/article-page/5.4/csharp/client-api/operations/patching/set-based#updating-by-document-id-using-parameters

from @all_docs as d
where id() in ($ids)
update { d.Updated = true; }

或者,从specific collection:

from Companies
update { this.Name = 'newName'; }

Learn also about Patching here:
https://ravendb.net/learn/inside-ravendb-book/reader/4.0/4-deep-dive-into-the-ravendb-client-api#patching-documents-and-concurrent-modifications

Sql相关问答推荐

在数据分区内执行确定

如何根据给定条件PostgreSQL迭代减少组中的行数

如何设计一个调用嵌套函数并仅在所有被调用的嵌套函数都提交时才提交的事务,例如,如果一个子函数失败则中止?

Oracle分层查询-两条路径在末尾合并为一条

每个学校 Select N个最新的行,但跳过同一学生的重复行

如何在多列上编写具有不同条件的查询?

使用同一个表,为什么IN、NOT IN、NOT EXISTS和EXISTS有不同的输出?

如何在T-SQL中编写row_number的WHERE子句?

为什么左联接结果在MS Access数据库中不匹配

如何在android房间中进行多个加入

从输出中删除 jsonb_build_object

当 2 列具有静态值并且第 3 列使用运算符 IN 时,对 PostgreSQL 和 3 列上的复杂索引的最佳查询

如何使用SELECT语句进行左连接,并根据右表中的特定值过滤结果?

PostgreSQL如何将Unix纪元时间戳转换为日期时间并进行拼接

String_Split 多列

计算 PostgreSQL 中的平均会话长度

连续日期的SQL

ACCESS SQL - 有没有办法使用通配符仅 Select 字段的特定部分?

使用一组值进行分组和计数

Lag() 获取snowflake的值变化