How to create macro to implement get function of Ecto?

Repo.get/1 only covers one primary key id.
I want to create macro that implements get function with multiple primary keys.

My first try

  defmacro defquery(:get) do
    module = __CALLER__.module
    primary_keys = module.__schema__(:primary_key)

    args =
      0..(Enum.count(primary_keys) - 1)
      |> Enum.map(&Macro.var(&1, module))

    quote do
      def get(unquote_splicing(args)) do
        ... 
      end
    end
  end

But module doesn’t have __schema__ when that macro runs.

So, my second try


  defmacro defquery(:get, primary_keys) do
    module = __CALLER__.module

    args =
      primary_keys
      |> Enum.map(&Macro.var(&1, module))

    quote do
      def get(unquote_splicing(args)) do
        ...
      end
    end
  end

But I don’t know how to write something like Repo.get_by([pk1: pk1, pk2: pk2]) dynamically.