add route index

This commit is contained in:
2021-05-20 15:22:46 +02:00
parent d2b95b4aea
commit 34199ece45
2 changed files with 21 additions and 1 deletions
@@ -0,0 +1,19 @@
using Raven.Client.Documents.Indexes;
using System.Linq;
using zero.Core.Routing;
namespace zero.Core.Database.Indexes
{
public class Routes_ForResolver : AbstractIndexCreationTask<Route>
{
public Routes_ForResolver()
{
Map = items => items
.Select(x => new
{
Url = x.Url,
AllowSuffix = x.AllowSuffix
});
}
}
}
+2 -1
View File
@@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using zero.Core.Database;
using zero.Core.Database.Indexes;
using zero.Core.Entities;
using zero.Core.Extensions;
using zero.Core.Options;
@@ -138,7 +139,7 @@ namespace zero.Core.Routing
min -= 1;
}
IList<Route> routes = await session.Query<Route>()
IList<Route> routes = await session.Query<Route, Routes_ForResolver>()
.Where(x => (!x.AllowSuffix && x.Url == path) || (x.AllowSuffix && x.Url.In(parts)))
.Include("References[].Id")
.Include("Dependencies")