|
|
@ -76,9 +76,9 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
{ |
|
|
{ |
|
|
var find = Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted); |
|
|
var find = Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted); |
|
|
|
|
|
|
|
|
using (var cursor = await find.ToCursorAsync(ct = default)) |
|
|
using (var cursor = await find.ToCursorAsync(ct)) |
|
|
{ |
|
|
{ |
|
|
while (await cursor.MoveNextAsync(ct = default)) |
|
|
while (await cursor.MoveNextAsync(ct)) |
|
|
{ |
|
|
{ |
|
|
foreach (var entity in cursor.Current) |
|
|
foreach (var entity in cursor.Current) |
|
|
{ |
|
|
{ |
|
|
@ -103,7 +103,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
await Collection.Find(filter).SortByDescending(x => x.LastModified).ThenBy(x => x.Id) |
|
|
await Collection.Find(filter).SortByDescending(x => x.LastModified).ThenBy(x => x.Id) |
|
|
.QueryLimit(q.Query) |
|
|
.QueryLimit(q.Query) |
|
|
.QuerySkip(q.Query) |
|
|
.QuerySkip(q.Query) |
|
|
.ToListAsync(ct = default); |
|
|
.ToListAsync(ct); |
|
|
long assetTotal = assetEntities.Count; |
|
|
long assetTotal = assetEntities.Count; |
|
|
|
|
|
|
|
|
if (q.NoTotal) |
|
|
if (q.NoTotal) |
|
|
@ -112,7 +112,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
} |
|
|
} |
|
|
else if (assetEntities.Count >= q.Query.Take || q.Query.Skip > 0) |
|
|
else if (assetEntities.Count >= q.Query.Take || q.Query.Skip > 0) |
|
|
{ |
|
|
{ |
|
|
assetTotal = await Collection.Find(filter).CountDocumentsAsync(ct = default); |
|
|
assetTotal = await Collection.Find(filter).CountDocumentsAsync(ct); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ResultList.Create(assetTotal, assetEntities.OfType<IAssetEntity>()); |
|
|
return ResultList.Create(assetTotal, assetEntities.OfType<IAssetEntity>()); |
|
|
@ -128,7 +128,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
.QueryLimit(query) |
|
|
.QueryLimit(query) |
|
|
.QuerySkip(query) |
|
|
.QuerySkip(query) |
|
|
.QuerySort(query) |
|
|
.QuerySort(query) |
|
|
.ToListAsync(ct = default); |
|
|
.ToListAsync(ct); |
|
|
long assetTotal = assetEntities.Count; |
|
|
long assetTotal = assetEntities.Count; |
|
|
|
|
|
|
|
|
if (q.NoTotal) |
|
|
if (q.NoTotal) |
|
|
@ -137,7 +137,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
} |
|
|
} |
|
|
else if (assetEntities.Count >= q.Query.Take || q.Query.Skip > 0) |
|
|
else if (assetEntities.Count >= q.Query.Take || q.Query.Skip > 0) |
|
|
{ |
|
|
{ |
|
|
assetTotal = await Collection.Find(filter).CountDocumentsAsync(ct = default); |
|
|
assetTotal = await Collection.Find(filter).CountDocumentsAsync(ct); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ResultList.Create<IAssetEntity>(assetTotal, assetEntities); |
|
|
return ResultList.Create<IAssetEntity>(assetTotal, assetEntities); |
|
|
@ -157,7 +157,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
{ |
|
|
{ |
|
|
var assetEntities = |
|
|
var assetEntities = |
|
|
await Collection.Find(BuildFilter(appId, ids)).Only(x => x.Id) |
|
|
await Collection.Find(BuildFilter(appId, ids)).Only(x => x.Id) |
|
|
.ToListAsync(ct = default); |
|
|
.ToListAsync(ct); |
|
|
|
|
|
|
|
|
var field = Field.Of<MongoAssetFolderEntity>(x => nameof(x.Id)); |
|
|
var field = Field.Of<MongoAssetFolderEntity>(x => nameof(x.Id)); |
|
|
|
|
|
|
|
|
@ -172,7 +172,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
{ |
|
|
{ |
|
|
var assetEntities = |
|
|
var assetEntities = |
|
|
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.ParentId == parentId).Only(x => x.Id) |
|
|
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.ParentId == parentId).Only(x => x.Id) |
|
|
.ToListAsync(ct = default); |
|
|
.ToListAsync(ct); |
|
|
|
|
|
|
|
|
var field = Field.Of<MongoAssetFolderEntity>(x => nameof(x.Id)); |
|
|
var field = Field.Of<MongoAssetFolderEntity>(x => nameof(x.Id)); |
|
|
|
|
|
|
|
|
@ -187,7 +187,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
{ |
|
|
{ |
|
|
var assetEntity = |
|
|
var assetEntity = |
|
|
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.FileHash == hash && x.FileName == fileName && x.FileSize == fileSize) |
|
|
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.FileHash == hash && x.FileName == fileName && x.FileSize == fileSize) |
|
|
.FirstOrDefaultAsync(ct = default); |
|
|
.FirstOrDefaultAsync(ct); |
|
|
|
|
|
|
|
|
return assetEntity; |
|
|
return assetEntity; |
|
|
} |
|
|
} |
|
|
@ -200,7 +200,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
{ |
|
|
{ |
|
|
var assetEntity = |
|
|
var assetEntity = |
|
|
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.Slug == slug) |
|
|
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.Slug == slug) |
|
|
.FirstOrDefaultAsync(ct = default); |
|
|
.FirstOrDefaultAsync(ct); |
|
|
|
|
|
|
|
|
return assetEntity; |
|
|
return assetEntity; |
|
|
} |
|
|
} |
|
|
@ -215,7 +215,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
|
|
|
|
|
|
var assetEntity = |
|
|
var assetEntity = |
|
|
await Collection.Find(x => x.DocumentId == documentId && !x.IsDeleted) |
|
|
await Collection.Find(x => x.DocumentId == documentId && !x.IsDeleted) |
|
|
.FirstOrDefaultAsync(ct = default); |
|
|
.FirstOrDefaultAsync(ct); |
|
|
|
|
|
|
|
|
return assetEntity; |
|
|
return assetEntity; |
|
|
} |
|
|
} |
|
|
@ -228,7 +228,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets |
|
|
{ |
|
|
{ |
|
|
var assetEntity = |
|
|
var assetEntity = |
|
|
await Collection.Find(x => x.Id == id && !x.IsDeleted) |
|
|
await Collection.Find(x => x.Id == id && !x.IsDeleted) |
|
|
.FirstOrDefaultAsync(ct = default); |
|
|
.FirstOrDefaultAsync(ct); |
|
|
|
|
|
|
|
|
return assetEntity; |
|
|
return assetEntity; |
|
|
} |
|
|
} |
|
|
|