Insert Data into MongoDB - Flutter

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 76

  • @crazyvolt1660
    @crazyvolt1660 6 месяцев назад +1

    Thank you, Im a student of Flutter, and this tutorial helped me a lot. :)

  • @George-or3uv
    @George-or3uv 2 года назад +4

    Excellent work. I cannot tell you how long that I have been waiting for a tutorial like this!

  • @wissalmahdi1167
    @wissalmahdi1167 2 года назад +1

    Very helpful thanx a lot

  • @speedtnt7591
    @speedtnt7591 2 года назад +1

    thank you but shall we use node.js? or we can make or models with just flutter and mongodb?

  • @guilhermelincoln8574
    @guilhermelincoln8574 2 года назад

    perfect my friend 🙏

  • @shahanasheikh9814
    @shahanasheikh9814 2 года назад

    man you are making amazing tutorials! keep it up.... but the only problem is the big text on screen stays for a much longer time kindly keep it only for 2- 3 seconds. Thankyou again

    • @DevMensIT
      @DevMensIT  2 года назад

      Thanks. I will try ☺️

  • @boneclinkz5663
    @boneclinkz5663 7 месяцев назад

    question, can i insert and store any media files such as mp4, collada,obj and svg?

    • @DevMensIT
      @DevMensIT  7 месяцев назад

      For that you should use storage

  • @bloomingtonsdirect6921
    @bloomingtonsdirect6921 2 года назад

    why do we need to refresh the browser to display the data in collection?

    • @DevMensIT
      @DevMensIT  2 года назад

      Because it wasn't auto refreshed so i manually did that thing for new data.

  • @BrentSancken
    @BrentSancken 2 года назад

    Hey! I followed through to the Querying video and as part of the Update you added lines 25-32 with the ModalRoute to the insert.dart file and if I go back and try to display the MongoDbInsert() as my homepage after that point, it doesn't work. I assume because it's expecting data from the previous screen but since there is none, it's null. How would I fix this/ be able to have access to Inserting new records as well as updating/deleting them?
    Exception is _CastError (type 'Null' is not a subtype of type 'MongoDbModel' in type cast)

    • @DevMensIT
      @DevMensIT  2 года назад

      sorry for my later reply...
      just give MongoDbModel? data :)
      if you will pass null it will work too

    • @MikArt
      @MikArt 2 года назад

      @@DevMensIT didn't work for me

    • @DevMensIT
      @DevMensIT  2 года назад

      @@MikArt can you share your error ?

  • @พงศนาถขันอาสา-ฎ9ฉ

    The MongoDB you are using is SQL ,NoSQL?

    • @DevMensIT
      @DevMensIT  2 года назад

      MongoDB is NoSQL database

  • @HoplandMusic
    @HoplandMusic 2 года назад

    Hey man! Great video! Would you be able to share a github link with your code?

    • @DevMensIT
      @DevMensIT  2 года назад +1

      Sorry we don't keep code.
      Our intention is to teach only.

  • @SaiBhot
    @SaiBhot 2 года назад

    Bro I followed each and every steps you mentioned,
    In the end a snackbar appears with the message "Inserted"
    But when I refresh the MongoDb database
    It shows NO RECORD FOUND

    • @DevMensIT
      @DevMensIT  2 года назад

      Debug your insert query maybe you missing something

    • @SaiBhot
      @SaiBhot 2 года назад

      Its the exact same thing and same lines i copied from you

    • @DevMensIT
      @DevMensIT  2 года назад

      @@SaiBhot share your connection code and insert code

    • @SaiBhot
      @SaiBhot 2 года назад

      @@DevMensIT class MongoDatabase {
      static var db, userCollection;
      static connect() async {
      db = await Db.create(MONGO_CONN_URL);
      await db.open();
      userCollection = db.collection(USER_COLLECTION);
      }
      static Future insert(add_MongoDBModel data) async {
      try {
      var result = await userCollection.insertOne(data.toJson());
      if (result.isSuccess) {
      return "Data inserted";
      } else {
      return "Something's Wrong";
      }
      return result;
      } catch (e) {
      return e.toString();
      }
      }
      }

    • @SaiBhot
      @SaiBhot 2 года назад

      Future _insertdata(String fname, String lname, String rollno) async {
      var id = m.ObjectId();
      final data = add_MongoDBModel(
      id: id, firstName: fname, lastName: lname, rollNo: rollno);
      var result = await MongoDatabase.insert(data);
      ScaffoldMessenger.of(context)
      .showSnackBar(const SnackBar(content: Text("Inserted")));
      _clearAll();
      }

  • @saijivanmaheswaran6337
    @saijivanmaheswaran6337 2 года назад +1

    Hey man! Nice Video!!
    I followed all steps but at very end, when i click on insert data, its displaying that "inserted id 6893xxxxxxx" but when i refresh database, it wont show me. (I am trying webbased)
    Can you help me out here?
    BTW when i debug, it says
    "Launching lib\main.dart on Windows in debug mode...
    Exception: Unable to find suitable Visual Studio toolchain. Please run `flutter doctor` for more details.
    Exited (sigterm)
    "
    after insert, i get this in my terminal:
    NoSuchMethodError: 'insertOne'
    Dynamic call of null.
    Receiver: null
    Arguments: [Instance of 'IdentityMap']
    NoSuchMethodError: 'insertOne'
    Dynamic call of null.
    Receiver: null
    Arguments: [Instance of 'IdentityMap']

    • @DevMensIT
      @DevMensIT  2 года назад

      Show your output of
      Flutter doctor -v

    • @saijivanmaheswaran6337
      @saijivanmaheswaran6337 2 года назад

      @@DevMensIT hey, dou you have discord, mail or anything? i tried to send it 4 times over comment sectiona nd wasnt able to post it :/ (also thanks to quick response!!)

    • @DevMensIT
      @DevMensIT  2 года назад

      Go to about in channel you will find out telegram link join that and ask your question there.

    • @saijivanmaheswaran6337
      @saijivanmaheswaran6337 2 года назад +1

      @@DevMensIT Just posted it :)

    • @saijivanmaheswaran6337
      @saijivanmaheswaran6337 2 года назад

      Hey @The Dev Man I got a quick question. Inside MongoDBModel.dart -> should "final mongoDbModal = mongoDbModalFromJson(jsonString);" be commented out or not?

  • @thismyname6832
    @thismyname6832 2 года назад

    This is what i get in the terminal when i try to insert the generated data:
    NoSuchMethodError: 'insertOne'
    Dynamic call of null.
    Receiver: null
    Arguments: [Instance of 'IdentityMap']

    • @thismyname6832
      @thismyname6832 2 года назад

      The data doesnt show on my db

    • @DevMensIT
      @DevMensIT  2 года назад

      @@thismyname6832 i think something wrong with model class.

    • @thismyname6832
      @thismyname6832 2 года назад

      @@DevMensIT i just checked but i dont see an issue there

    • @DevMensIT
      @DevMensIT  2 года назад

      @@thismyname6832 did you follow steps correct ?

    • @thismyname6832
      @thismyname6832 2 года назад +1

      @@DevMensIT when i do flutter run this is the issue that appears:
      Error: MongoDB ConnectionException: Could not connect to (db cluster)
      - Unsupported operation: default SecurityContext getter
      And then a bunch of text

  • @tonxayinpaserd4465
    @tonxayinpaserd4465 2 года назад

    How to upload images?

    • @DevMensIT
      @DevMensIT  2 года назад

      Where do you want to upload ?

    • @tonxayinpaserd4465
      @tonxayinpaserd4465 2 года назад

      @@DevMensIT When will you make a video clip upload your photos to mongodb with flutter?

    • @DevMensIT
      @DevMensIT  2 года назад

      @@tonxayinpaserd4465 i don't know yet about mongodb storage. But you can use Base64 to store image string inside database

    • @tonxayinpaserd4465
      @tonxayinpaserd4465 2 года назад

      @@DevMensIT thank bro

  • @firashk2161
    @firashk2161 2 года назад

    good video bro

    • @DevMensIT
      @DevMensIT  2 года назад +1

      so you want to store notification only on mongoDB ?
      Yeah that possible to store your notification on mongoDB instead of local database. just you have to know how to read your notification and when they popup just call function. :)

    • @firashk2161
      @firashk2161 2 года назад

      @@DevMensIT yep i want to store data in mongo..so when you follow me for exemple..i get the notification and then that notification automatically added to mongo..soo when i visit notification interface in my app..i see all the notification i received..such as follow or like or comment..etc..but the problem how ? hhhh i dont know how to do that..all i found on youtube are using firebase but i want mongo

    • @DevMensIT
      @DevMensIT  2 года назад +1

      @@firashk2161 which notification service are you using for send push notifications to user device ?

    • @firashk2161
      @firashk2161 2 года назад +1

      @@DevMensIT for now i still have static notification i follow videos on push notifications..so when u click on button a notification popup..but as i said i dont know how to make it dynamic and saved to mongo so i can show them later

    • @DevMensIT
      @DevMensIT  2 года назад +1

      @@firashk2161 there will be function regarding notification handle.
      Check out firebase messaging (Cloud Messaging)

  • @meetpanchal9708
    @meetpanchal9708 Год назад

    sir everything works fine but database is not reflecting the changes

    • @DevMensIT
      @DevMensIT  Год назад

      Check whether data is inserting or not

    • @meetpanchal9708
      @meetpanchal9708 Год назад

      @@DevMensIT sir even the database is connected to the app

    • @meetpanchal9708
      @meetpanchal9708 Год назад

      @@DevMensIT how to check that sir?

    • @DevMensIT
      @DevMensIT  Год назад

      Check response of insert query

    • @meetpanchal9708
      @meetpanchal9708 Год назад

      @@DevMensIT by any way I can show you my code