stablekernel / aqueduct

Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.
https://aqueduct.io
BSD 2-Clause "Simplified" License
2.41k stars 280 forks source link

Support for ORMs database support #228

Closed fredtma closed 7 years ago

fredtma commented 7 years ago

Totally new to Dart and Aquaduct (nodeJs dev). Reading the documentation I do not see support for document orientated database (mongo). Is there plan to support this?

joeconwaystk commented 7 years ago

For MongoDB, we've used: https://pub.dartlang.org/packages/mongo_dart.

There isn't a plan to support document databases with the ORM. I recognize that it's common to use a MongoDB "ODM" in NodeJS, but to be honest, I never understood the point. What are some of the compelling reasons I'm missing for having ORM-like behavior on a document database?

suragch commented 5 years ago

On a related note for future visitors, Aqueduct 3.0 includes support for JSONB columns. Quote from here:

The Aqueduct ORM now supports PostgreSQL JSONB columns. JSONB columns store JSON data, similar to key-value databases like MongoDB. An example usage of a JSONB column looks like this:

 final query = Query(context)
   ..values.timestamp = DateTime.now()
   ..values.contents = Document({
     "type": "push",
     "user": "bob",
     "tags": ["v1"]
   });
 final event = await query.insert(); 

Documentation on using JSONB columns is available here.

kralos commented 3 years ago

@joeconwaystk

What are some of the compelling reasons I'm missing for having ORM-like behavior on a document database?

Mostly consistency in translation between a database document and a language model.

e.g.

mongo dart
ObjectId String
ISODate DateTime

I believe mongo_dart provides this to a degree.

If using annotations in dart to describe validation constraints on the dart model then it provides a consistent place for those to live on the consistently hydrated dart model.

A query builder can give some advantage when exposing some kind of dynamic filter system to a user or api. I would advise against using a query builder for any static application queries.