mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update mongodb
This commit is contained in:
parent
a7837ddf8f
commit
3efd6ed7f9
@ -1,4 +1,8 @@
|
|||||||
using System;
|
using MongoDb.Ado.data;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Metrics;
|
using System.Diagnostics.Metrics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -250,6 +254,13 @@ namespace SqlSugar.MongoDb
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
public override bool TruncateTable(string tableName)
|
||||||
|
{
|
||||||
|
var db =((MongoDbConnection)this.Context.Ado.Connection).GetDatabase();
|
||||||
|
db.GetCollection<BsonDocument>(tableName)
|
||||||
|
.DeleteMany(FilterDefinition<BsonDocument>.Empty);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public override List<string> GetIndexList(string tableName)
|
public override List<string> GetIndexList(string tableName)
|
||||||
{
|
{
|
||||||
var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}')";
|
var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}')";
|
||||||
|
@ -86,6 +86,8 @@ namespace SqlSugar.MongoDb
|
|||||||
#region OrderBy
|
#region OrderBy
|
||||||
var order = this.GetOrderByString;
|
var order = this.GetOrderByString;
|
||||||
var orderByString = this.GetOrderByString?.Trim();
|
var orderByString = this.GetOrderByString?.Trim();
|
||||||
|
if (orderByString == "ORDER BY NOW()")
|
||||||
|
orderByString = null;
|
||||||
if (!string.IsNullOrEmpty(orderByString) && orderByString.StartsWith("ORDER BY ", StringComparison.OrdinalIgnoreCase))
|
if (!string.IsNullOrEmpty(orderByString) && orderByString.StartsWith("ORDER BY ", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
order = order.Substring("ORDER BY ".Length).Trim();
|
order = order.Substring("ORDER BY ".Length).Trim();
|
||||||
|
Loading…
Reference in New Issue
Block a user