2021-11-20 13:52:28 +01:00
|
|
|
using Raven.Client.Documents.Indexes;
|
|
|
|
|
|
|
|
|
|
namespace zero.Media;
|
|
|
|
|
|
|
|
|
|
public class Media_ByParent : ZeroMultiMapIndex<MediaListItem>
|
|
|
|
|
{
|
|
|
|
|
protected override void Create()
|
|
|
|
|
{
|
2021-11-26 11:21:49 +01:00
|
|
|
AddMap<Media>(items => items.Select(item => new MediaListItem
|
2021-11-20 13:52:28 +01:00
|
|
|
{
|
|
|
|
|
Id = item.Id,
|
|
|
|
|
ParentId = item.ParentId,
|
|
|
|
|
CreatedDate = item.CreatedDate,
|
|
|
|
|
IsFolder = false,
|
|
|
|
|
Name = item.Name,
|
2021-12-18 01:51:38 +01:00
|
|
|
Image = item.ImageMeta != null ? item.ImageMeta.Thumbnails["thumb"] : null,
|
2021-11-20 13:52:28 +01:00
|
|
|
Children = 0,
|
|
|
|
|
Size = item.Size,
|
|
|
|
|
IsShared = item.Blueprint != null,
|
|
|
|
|
AspectRatio = item.ImageMeta != null ? (float)item.ImageMeta.Width / item.ImageMeta.Height : 0
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
StoreAllFields(FieldStorage.Yes);
|
|
|
|
|
Index(x => x.ParentId, FieldIndexing.Exact);
|
|
|
|
|
}
|
|
|
|
|
}
|