Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (39 sloc) 1.48 KB
using System;
using System.Linq;
using RaccoonBlog.Web.Models;
using Raven.Abstractions.Indexing;
using Raven.Client.Indexes;
namespace RaccoonBlog.Web.Infrastructure.Indexes
{
public class PostComments_CreationDate : AbstractIndexCreationTask<PostComments, PostComments_CreationDate.ReduceResult>
{
public class ReduceResult
{
public DateTimeOffset CreatedAt { get; set; }
public int CommentId { get; set; }
public string PostCommentsId { get; set; }
public string PostId { get; set; }
public DateTimeOffset PostPublishAt { get; set; }
}
public PostComments_CreationDate()
{
Map = postComments => from postComment in postComments
from comment in postComment.Comments
where comment.IsSpam == false
select new
{
comment.CreatedAt,
CommentId = comment.Id,
PostCommentsId = postComment.Id,
PostId = postComment.Post.Id,
PostPublishAt = postComment.Post.PublishAt
};
Store(x => x.CreatedAt, FieldStorage.Yes);
Store(x => x.CommentId, FieldStorage.Yes);
Store(x => x.PostId, FieldStorage.Yes);
Store(x => x.PostCommentsId, FieldStorage.Yes);
Store(x => x.PostPublishAt, FieldStorage.Yes);
MaxIndexOutputsPerDocument = 512;
}
}
}
Something went wrong with that request. Please try again.