I am trying to connect my mongodb to flutter and this is how my database.dart file looks
import 'package:mongo_dart/mongo_dart.dart';
import 'package:restro_app/database/constant.dart';
import 'package:restro_app/models/menu_model.dart';
class MongoDatabase {
static var db, userCollection;
//Connection to the database
static connect() async {
db = await Db.create(MONGO_CONN_URL);
await db.open();
userCollection = db.collection(DATA_COLLECTION);
}
// More code..
But when I started to debug I realised that the variable db isn't getting any values
it returns Db(null, null)
const MONGO_CONN_URL = "mongodb+srv://127.0.0.1:27017/Restaurant";
This is how my connection string looks
Not sure what is going wrong
Hi π
127.0.0.1 - is localhost?
You need to use public IP or a domain to connect to their MongoDB server.
FYI, since this is an Appwrite (https://appwrite.io/) discord server, for general flutter questions, you might find more help in a Flutter discord server (https://flutter.dev/community#community-grid).
[SOLVED] How to connect MongoDB with flutter
Closing this thread for now, if you have appwrite specific questions, please open a new thread π
Recommended threads
- MongoDb Database Breaks integer[] & bigi...
I've got a table with the below column created. When I try to insert the value `[-3408048000]` into it, the dart sdk cloud function call is successful (no error...
- 1.9.6 Console handles all array columns ...
When creating or updating a row in the appwrite 1.9.6 web console, the form treats all list columns as a type string. Even if the column is a list of booleans, ...
- Temporary $permissions hickup?
Hello, today at ~13:50 (CEST/UTC+2) our customers reported they couldn't see any data in our application. We checked and indeed, the application was working, bu...