嵌套集合条件下的RavenDb DeleteByIndex
假设我有一个模式,如下所示:嵌套集合条件下的RavenDb DeleteByIndex,ravendb,Ravendb,假设我有一个模式,如下所示: Father { // Type: 1 Id } Mother { // Type: 2 Id } Child { Parents: [ { ParentId, ParentType } // ParentType could be 1 or 2 acording to entity's type ] } Map = views => from view in views select new { view.Pa
Father { // Type: 1
Id
}
Mother { // Type: 2
Id
}
Child {
Parents: [
{ ParentId, ParentType } // ParentType could be 1 or 2 acording to entity's type
]
}
Map = views => from view in views
select new
{
view.ParentId,
view.ParentType,
view.Parents
}
如何创建一个允许我们删除ByIndex并接受lucene查询的索引,例如:“Parents,ParentId:xyz和Parents,ParentType:2”
当我尝试创建索引时,如下所示:
Father { // Type: 1
Id
}
Mother { // Type: 2
Id
}
Child {
Parents: [
{ ParentId, ParentType } // ParentType could be 1 or 2 acording to entity's type
]
}
Map = views => from view in views
select new
{
view.ParentId,
view.ParentType,
view.Parents
}
RavenDb未能删除,并表示“Parents,ParentId”尚未编制索引。
这样做的原因是,当它是{Mother,Father}之一的子数据时,我想删除所有子数据。语法
Parents,ParentId
仅适用于动态索引,使用静态索引,定义字段名,并且可以根据需要命名它们
Map = views => from view in views
from parent in view.Parents
select new
{
parent .ParentId,
parent .ParentType
}
但是,如果您的系统可以有多个父项,请查看文档中关于扇出索引的内容。语法
parents,ParentId
仅适用于动态索引,使用静态索引,您可以定义字段名,并且可以根据需要命名它们
Map = views => from view in views
from parent in view.Parents
select new
{
parent .ParentId,
parent .ParentType
}
但是,如果您的系统可以有多个父级,请查看文档中关于扇出索引的内容