From 5fb4fe5aaf6387d89e4aa19f8df7c5231fd80f07 Mon Sep 17 00:00:00 2001 From: Jameson2011 Date: Thu, 11 Jun 2020 18:46:43 +0100 Subject: [PATCH] fix deprecations --- src/zKbProxy/KillProviderActor.fs | 2 +- src/zKbProxy/MongoDb.fs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zKbProxy/KillProviderActor.fs b/src/zKbProxy/KillProviderActor.fs index c7eb30b..25da6c9 100644 --- a/src/zKbProxy/KillProviderActor.fs +++ b/src/zKbProxy/KillProviderActor.fs @@ -39,7 +39,7 @@ type KillProviderActor(log: PostMessage, stats: PostMessage, config: Configurati let getKillCount()= async { try - return! (dbCollection.CountAsync(fun _ -> true) |> Async.AwaitTask) + return! (dbCollection.CountDocumentsAsync(fun _ -> true) |> Async.AwaitTask) with | e -> logException e return 0L diff --git a/src/zKbProxy/MongoDb.fs b/src/zKbProxy/MongoDb.fs index a45928d..4f59242 100644 --- a/src/zKbProxy/MongoDb.fs +++ b/src/zKbProxy/MongoDb.fs @@ -87,9 +87,9 @@ let setIndex (path: string) (collection: IMongoCollection<'a>) = let json = sprintf "{'%s': 1 }" path let def = IndexKeysDefinition<'a>.op_Implicit(json) + let model = CreateIndexModel<'a>(def) + let r = collection.Indexes.CreateOne(model) - let r = collection.Indexes.CreateOne(def) - collection let getCollection colName (db: IMongoDatabase) = @@ -113,14 +113,14 @@ initCollection "" server dbName collectionName userName password let upsert (collection: IMongoCollection) (doc: BsonDocument) = - let opts = UpdateOptions() + let opts = ReplaceOptions() opts.IsUpsert <- true - let filter = doc |> Bson.getId |> idFilter |> Bson.ofJson |> FilterDefinition.op_Implicit collection.ReplaceOne(filter, doc, opts) |> ignore + let delete (collection: IMongoCollection) id = let filter = id |> idFilter |> Bson.ofJson