Dart interaction / access to database

前端 未结 5 1487
情话喂你
情话喂你 2021-02-05 12:38

How can Dart (running server side) access a database ?

Can I execute SQL-Statements directly or can I use some kind of ORM?

相关标签:
5条回答
  • 2021-02-05 12:44

    This hits on a larger question of migrating from current architectures such as CakePHP and RoR to Dart. Dart is very new and does not provide much functionality on the server side, not having db drivers is the least of your problems - Dart is lacking a tried and battle proven MVC framework which means that it is almost ludicrous to imagine migrating from CakePHP for the sake of argument to Dart.

    In a situation where you want to try and start converging to the Dart goals - it would make sense NOT to access the db directly from Dart but to use RESTful services in an existing MVC framework.

    This provides a much cleaner and robust interface than coding to SQL in Dart and provides a good migration path.

    0 讨论(0)
  • 2021-02-05 12:53

    There is a mongoDb driver that Vadim Tsushko has released. It was mentioned on the : dartlang news recently.

    Pastebin for example usage.

    Update: I've also blogged about it's usage on the dartwatch blog

    0 讨论(0)
  • 2021-02-05 12:55

    There is also a Windows MS-SQL Server driver available at https://pub.dev/packages/dart_mssql

    0 讨论(0)
  • 2021-02-05 13:06

    There is also a Redis driver available: https://github.com/mythz/DartRedisClient

    0 讨论(0)
  • 2021-02-05 13:08

    Currently there is no Database API for Dart that rivals ODBC/JDBC, also to my knowledge there is no ORM. There will definitely be such a thing in the future, also the Dart SDK will eventually allow you to bind native code against it making it easier to provide database access by linking against existing database libraries.

    I am myself currently using Riak on Dart via its REST interface, which works well for small applications but for something more serious we will have to await better SDK support.

    Note: client side databases such as IndexDB and WebSQL are in the process of being added to dart:html right now.

    Update: There is now a MongoDB driver and we are working on a driver for Amazon's DynamoDB

    Update 2: Drivers are now available for mysql and postgresql.

    0 讨论(0)
提交回复
热议问题