Fix for activating mongodb connection

This commit is contained in:
Морозов Андрей 2022-09-24 22:17:36 +04:00
parent 813658f934
commit 741b904fd8
4 changed files with 14 additions and 15 deletions

View File

@ -16,7 +16,7 @@ class DataSingleton {
List<String> gridData = [""]; List<String> gridData = [""];
Map<String, Color> coloredLetters = {}; Map<String, Color> coloredLetters = {};
int currentWordIndex = 0; int currentWordIndex = 0;
late DBConnection _mongo; final DBConnection _mongo = DBConnection();
factory DataSingleton() { factory DataSingleton() {
return _dataSingleton; return _dataSingleton;
@ -81,6 +81,7 @@ class DataSingleton {
} }
} else { } else {
_mongo.insertWord(secretWord, false); _mongo.insertWord(secretWord, false);
_mongo.loseConnection();
return LoseGameState(); return LoseGameState();
} }
} }

View File

@ -17,6 +17,10 @@ class DBConnection {
final String _dbName = "DATABASE NAME"; final String _dbName = "DATABASE NAME";
final String _collectionName = "WordsTable"; final String _collectionName = "WordsTable";
DBConnection() {
startConnection();
}
late Db _db; late Db _db;
late final DbCollection _collection = _db.collection(_collectionName); late final DbCollection _collection = _db.collection(_collectionName);

View File

@ -14,7 +14,7 @@ packages:
name: basic_utils name: basic_utils
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.5.2" version: "3.9.4"
bloc: bloc:
dependency: "direct main" dependency: "direct main"
description: description:
@ -30,12 +30,12 @@ packages:
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
bson: bson:
dependency: transitive dependency: "direct main"
description: description:
name: bson name: bson
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "1.0.4"
buffer: buffer:
dependency: transitive dependency: transitive
description: description:
@ -92,13 +92,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
decimal:
dependency: transitive
description:
name: decimal
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
desktop_window: desktop_window:
dependency: "direct main" dependency: "direct main"
description: description:
@ -274,14 +267,14 @@ packages:
name: mongo_dart name: mongo_dart
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.0-1.0.beta" version: "0.7.4+1"
mongo_dart_query: mongo_dart_query:
dependency: transitive dependency: transitive
description: description:
name: mongo_dart_query name: mongo_dart_query
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "1.0.2"
nested: nested:
dependency: transitive dependency: transitive
description: description:
@ -421,7 +414,7 @@ packages:
name: rational name: rational
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.0" version: "1.2.1"
sasl_scram: sasl_scram:
dependency: transitive dependency: transitive
description: description:

View File

@ -23,7 +23,8 @@ dependencies:
fullscreen: ^1.0.3 fullscreen: ^1.0.3
file: ^6.1.4 file: ^6.1.4
bloc: ^8.1.0 bloc: ^8.1.0
mongo_dart: ^0.8.0-1.0.beta mongo_dart: ^0.7.4+1
bson: ^1.0.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: