dericop

dericop

Hi,

I’m using Ecto Mongodb and I want to configure a custom pool size in my plug project. I was testing a few solutions but i can’t do it successfully. Do you can help me?

This is my config.exs:

use Mix.Config

import_config "#{Mix.env()}.exs"

config :feature_flags, FeatureFlags.Repo,
       adapter: Mongo.Ecto,
       mongo_url: "mongodb://ip/db?"

This is my mix.exs:

defmodule FeatureFlags.MixProject do
  use Mix.Project

  def project do
    [
      app: :feature_flags,
      version: "0.1.0",
      elixir: "~> 1.9",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  def application do
    [
      extra_applications: [:logger, :plug_cowboy, :mongodb, :poolboy,:mongodb_ecto, :ecto],
      mod: {FeatureFlags.Application, []}
    ]
  end

  defp deps do
    [
      {:plug_cowboy, "~> 2.1"},
      {:poison, "~> 3.1"},
      {:mongodb, ">= 0.4.9"},
      {:mongodb_ecto, "~> 0.1"},
      {:poolboy, ">= 1.5.2"}
    ]
  end
end

This is my applications.exs:

defmodule FeatureFlags.Application do
  @moduledoc "OTP application spec for Feature Flags"

  use Application

  def start(_type, _args) do
    import Supervisor.Spec
    IO.inspect(DBConnection.Poolboy)


    children = [
      worker(FeatureFlags.Repo, []),
      # Use Plug.Cowboy to register the endpoint
      Plug.Cowboy.child_spec(
        scheme: :http,
        plug: FeatureFlags.AppRestEntryPoint,
        options: [port: Application.get_env(:feature_flags, :port)]
      )
    ]

    opts = [strategy: :one_for_one, name: FeatureFlags.Supervisor, pool_size: 40]
    Supervisor.start_link(children, opts)
  end
end

defmodule FeatureFlags.Repo do
  use Ecto.Repo, otp_app: :feature_flags
end

Thanks for your help.

Showing Posts 1 to 1

zookzook

zookzook

Hi dericop

instead of using Ecto with MongoDB it is a better way to use the driver api without any additional layer.

Ecto is made for SQL and MongoDB is very different. But that’s a philosophical question. In my opinion, Ecto is not necessary for the use of MongoDB. An additional level between the driver and the program is superfluous because the MongoDB documents are returned as maps. If you prefer defstructs, you can convert the maps into such. Queries as SQL-DSL are more of a headache for MongoDB and are not useful. Why should one describe MongoDB queries as SQL?

SQL-Injection in MongoDB is hardly possible because the queries do not have to be expressed as a strings but as keyword lists or maps.

Example:

Mongo.find_one(:mongo, "accounts", %{username: name}, limit: 1)

In this case you are not able to fake the query, because the content of name is always treated as value whatever it is. You don’t need to escape values here.

Good luck!

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews