Would you recommend using MongoDB with Phoenix with current driver status in mind?

Hello svsdehh,

I am new to Elixir and Phoenix. And I was wondering about the status of Mongodb support in Phoenix. So far the situation doesn’t look very promising for someone who is just starting with Elixir+Phoenix. Would you recommend Mongodb as a database for Phoenix application considering the use is perfectly suitable but compatibility of the current mongodb drivers with Phoenix is a concern? A person who is just started learning Elixir is not ready to dig deeper into the framework and implement libraries like rockstar developers.

Please share your views and experience.

Thanks,
Abhay

I don’t know that there’s ever a time that MongoDB is actually the correct choice.

5 Likes

Simple way to decide

         time series data -> Timescale (PostgreSQL based)
         globally distributed consist. transactional SQL don't care about $ -> Spanner
         need to store and search through random crap at large scale -> ElasticSearch
         need to absorb events at large scale and then process them -> Kafka 
         some very unusual workload and/or wiered requirements -> you'd have to do research and test :)
         _  ->  PostgreSQL
3 Likes

Ha Ha… I am not an expert so don’t know if my choice is good or not. Just that my Postgres skills are too weak and Mongodb is pretty easy to get started with for my simple application :slight_smile:

data
_Id bigserial
collection_id bigint
data jsonb
CREATE INDEX data_data_idx ON data USING gin (data)

There you have mongo but with a ton of extra features and transactions :slight_smile:

4 Likes

From a learning perspective you should probably stick to a vanilla configuration because that is what the documentation, blogs, books, videos, etc. assume anyway.

Now if you have a need to use MongoDB you may want to tackle that separately as an Elixir/MongoDB problem which may or may not include include Ecto (example: How to use MongoDB With Elixir - Revisited). With the Phoenix is not your application approach it should be possible to compartmentalize the MongoDB dependency in a distinct application that Phoenix is a client to.

Ah… I wish if I knew Postgres more so that I could start coding rather than worrying about the database part. Your “quick start” help is good but probably I will need to learn Postgres a bit more than that if I want use it for my app. Thanks though. I will see if I invest some time in learning Postgres in coming weeks.

You are right, peerreynders. I have been learning about how to use mongodb with Phoenix but looks like this requires little advance Elixir skills. I think I will have to learn Elixir + Phoenix first by going through the default configuration ie, using Postgres. And then, later in the future, look into Mongodb issue. I am sure I am not the only one who wants to use mongodb.

3 Likes

disclaimer: I am the current maintainer of both the mongodb and mongodb_ecto packages.

Unfortunately the MongoDB support in Elixir is a little lack luster. I would attribute it mostly to the fact that largely only a single person seems to work on it at any given time. There are of course large contributions that come along. With that said, replica set support semi-recently landed in the mongodb package. Unfortunately there were a number of issues with the initial implementation. So I am slowly trying to fix them. There are also a number of features I am wanting to address. Unfortunately I only have so much time in a day.

With that said, I am using it in production at the moment. So if you, or anyone else of that matter, have any questions about getting started, please let me know and I can update documentation or something to make it more easily understandable.

Edit: There is also #elixir-lang channel on freenode or the mongodb channel in the Elixir community slack group where I hang out if anyone has any questions.

6 Likes

Wonderful. Thanks Ankhers for the comment. I will give ‘mongodb’ a try as you are saying ‘mongodb’ has replicaset support. I will reach out to you in case I have an issue :slight_smile: Thanks :slight_smile:

1 Like

Actually you can make some headway without getting any database involved:

The advantage to this approach is that you get first introduced to using the “Phoenix is not your application” way before exploring “Phoenix is your application” - which is more like many RoR web applications are built.

2 Likes

Sounds like a good idea. I appreciate your help. I will go through the links you shared :slight_smile:

1 Like