Search code examples
mongodbphoenix-frameworkecto

is there a way to connect mongodb with phoenix framework 1.4 version


i am trying to use mongodb in my phoenix application. however the official documentation refers to only RDBMS (postgresql). is there a way to connect to mongodb with phoenix framework 1.4.

i am trying to build an application in phoenix which will have unstructured data. i see from the documentation of ECTO mongodb for old version. for 1.4 version of the phoenix, there is no option specified.


Solution

  • There does not appear to be a MongoDB/Ecto integration that is up to date with Ecto 3 yet.

    But Phoenix is not your application, it is an interface. It provides the web interface. You can have other things in your application apart from Phoenix, and you can wrap MongoDB in a way that your Phoenix-based-interface can consume the data.

    So the answer to your question is yes there is a way to connect MongoDB with Phoenix 1.4 but it is not plug-and-play.

    Edit: I threw (emphasis on threw) together an example which can be found here

    Some data in mongo Data in the Phoenix App enter image description here

    Basically it involves two applications: one a stock elixir application that is just mongodb 0.4.7 and wraps some functions. The other is a phoenix app that uses the aforementioned mongodb wrapper app. The Phoenix App needs to be created with mix phx.new --no-ecto, ostensibly you could do this as one app, but this gives you a bit more leeway.