Using the mongo_dart driver to store the todo data in MongoDB
MongoDB drivers exist for a whole range of programming languages, including Dart. We will use mongo_dart
in our app, which is a server-side driver implemented purely in Dart. Simply add mongo_dart: any
to your app's pubspec.yaml
, and issue pub install. In the code, write:
import 'package:mongo_dart/mongo_dart.dart';
todo_mongodb
is a version of todo_server_dartling_mysql
, but now use MongoDB as a persistent data source (clone the project from https://github.com/dzenanr/todo_mongodb). It contains a client app todo_client_idb
, identical to the one in the previous section, which stores data in IndexedDB
. The server part todo_server_dartling_mongodb
can be started by running bin/server.dart
; you should see in the editor or the console:
Server at http://127.0.0.1:8080;
If you see the following exception, it means that the mongod server has not yet been started:
SocketException: Connection failed (OS Error: No connection could be made because...