mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
IDataBase Last
IDataBase Last
This commit is contained in:
@@ -19,6 +19,7 @@ public interface IDateBase
|
||||
FTask<List<T>> QueryByPageOrderBy<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity;
|
||||
FTask<T> First<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
|
||||
FTask<T> First<T>(string json, string[] cols, string collection = null) where T : Entity;
|
||||
FTask<T> Last<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
|
||||
FTask<List<T>> QueryOrderBy<T>(Expression<Func<T, bool>> filter, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity;
|
||||
FTask<List<T>> Query<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
|
||||
FTask Query(long id, List<string> collectionNames, List<Entity> result);
|
||||
|
@@ -191,6 +191,18 @@ public sealed class MongoDataBase : IDateBase
|
||||
}
|
||||
}
|
||||
|
||||
public async FTask<T> Last<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity
|
||||
{
|
||||
using (await _mongoDataBaseLock.Lock(RandomHelper.RandInt64()))
|
||||
{
|
||||
var cursor = await GetCollection<T>(collection).FindAsync(filter);
|
||||
|
||||
var list = await cursor.ToListAsync();
|
||||
|
||||
return list.LastOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public async FTask<List<T>> QueryOrderBy<T>(Expression<Func<T, bool>> filter, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity
|
||||
{
|
||||
using (await _mongoDataBaseLock.Lock(RandomHelper.RandInt64()))
|
||||
|
@@ -39,7 +39,7 @@ namespace TEngine.Logic
|
||||
|
||||
public async FTask<uint> GeneratorUID(IDateBase db)
|
||||
{
|
||||
var ret = await db.First<AccountInfo>(t=>t.UID != 0);
|
||||
var ret = await db.Last<AccountInfo>(t=>t.UID != 0);
|
||||
if (ret == null)
|
||||
{
|
||||
return 100000;
|
||||
|
Reference in New Issue
Block a user