From 741b904fd8385fba98d2af2636b57b4f9cc59ce5 Mon Sep 17 00:00:00 2001 From: lnd212 Date: Sat, 24 Sep 2022 22:17:36 +0400 Subject: [PATCH] Fix for activating mongodb connection --- app/lib/core/data/data_singleton.dart | 3 ++- app/lib/core/data/mongodb.dart | 4 ++++ app/pubspec.lock | 19 ++++++------------- app/pubspec.yaml | 3 ++- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/lib/core/data/data_singleton.dart b/app/lib/core/data/data_singleton.dart index df88323..450f19e 100644 --- a/app/lib/core/data/data_singleton.dart +++ b/app/lib/core/data/data_singleton.dart @@ -16,7 +16,7 @@ class DataSingleton { List gridData = [""]; Map coloredLetters = {}; int currentWordIndex = 0; - late DBConnection _mongo; + final DBConnection _mongo = DBConnection(); factory DataSingleton() { return _dataSingleton; @@ -81,6 +81,7 @@ class DataSingleton { } } else { _mongo.insertWord(secretWord, false); + _mongo.loseConnection(); return LoseGameState(); } } diff --git a/app/lib/core/data/mongodb.dart b/app/lib/core/data/mongodb.dart index c44f06e..b2701f0 100644 --- a/app/lib/core/data/mongodb.dart +++ b/app/lib/core/data/mongodb.dart @@ -17,6 +17,10 @@ class DBConnection { final String _dbName = "DATABASE NAME"; final String _collectionName = "WordsTable"; + DBConnection() { + startConnection(); + } + late Db _db; late final DbCollection _collection = _db.collection(_collectionName); diff --git a/app/pubspec.lock b/app/pubspec.lock index eb6d02e..1db238e 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -14,7 +14,7 @@ packages: name: basic_utils url: "https://pub.dartlang.org" source: hosted - version: "4.5.2" + version: "3.9.4" bloc: dependency: "direct main" description: @@ -30,12 +30,12 @@ packages: source: hosted version: "2.1.0" bson: - dependency: transitive + dependency: "direct main" description: name: bson url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "1.0.4" buffer: dependency: transitive description: @@ -92,13 +92,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" - decimal: - dependency: transitive - description: - name: decimal - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.0" desktop_window: dependency: "direct main" description: @@ -274,14 +267,14 @@ packages: name: mongo_dart url: "https://pub.dartlang.org" source: hosted - version: "0.8.0-1.0.beta" + version: "0.7.4+1" mongo_dart_query: dependency: transitive description: name: mongo_dart_query url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "1.0.2" nested: dependency: transitive description: @@ -421,7 +414,7 @@ packages: name: rational url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "1.2.1" sasl_scram: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 3149abb..aa9abb9 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -23,7 +23,8 @@ dependencies: fullscreen: ^1.0.3 file: ^6.1.4 bloc: ^8.1.0 - mongo_dart: ^0.8.0-1.0.beta + mongo_dart: ^0.7.4+1 + bson: ^1.0.4 dev_dependencies: flutter_test: