Save data to mongodb through code

Currently you are trying to save your data during build time of your application.

This requires you to set up your database connection during build time manually and is probably not the thing you want. Especially not if this does not make sense to you.

But without knowing your exact architecture I think its hard to tell you how to do it properly.

But I assume you are doing a phoenix application here, so just call the save from your controller.