我正在尝试使用 RavenDB Studio 删除一个属性(将其添加到我寻求帮助的文档中,请参阅 here )(我不小心将它们添加到了错误的数据库集合中...)。
我再次陷入语法困境。另外 - 我不敢相信到目前为止没有人有这样做的意图 - 至少强烈的谷歌搜索无法产生任何有用的东西。至少可以说,官方文档关于这个主题也很简洁。 旁白:为什么 RavenDB(可能还有其他 NoSQL DB)中的 DDL 如此麻烦?
我尝试了各种版本
from things as t
update {
delete t.field
}
这些都不起作用,有些甚至无法编译。
最佳答案
通过修补 - 可以通过客户端代码以这种方式删除文档字段:
单个文档:
session.Advanced.Defer(new PatchCommandData(
id: "yourDocumentID",
changeVector: null,
patch: new PatchRequest
{
Script = @"delete this.fieldToDelete"
},
patchIfMissing: null));
session.SaveChanges();
参见:Patching - Removing Property
多个文档:
var operation = store
.Operations
.Send(new PatchByQueryOperation("from things update { delete this.field; }"));
operation.WaitForCompletion();
示例取自 here
对于 RQL,只需使用:
from things
update {
delete this.field;
}
关于ravendb - 从 RavenDB Studio 中的集合中删除字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60495933/