Add @schema_context to set context on schema definition

83 views
Skip to first unread message

cevado

unread,
Jul 6, 2021, 5:11:45 PM7/6/21
to elixir-ecto
Currently the only possible  way to use context metadata is adding it to the schema with Ecto.put_meta/2. To be able to set a context on schema definition just as its possible to set a prefix with @schema_prefix would make context way more useful, exposing the set context with __schema__/1 would be nice too. Is there anything against doing that? 

José Valim

unread,
Jul 6, 2021, 5:12:37 PM7/6/21
to elixi...@googlegroups.com
Can you please tell us more about the use case?

On Tue, Jul 6, 2021 at 23:11 cevado <flav...@gmail.com> wrote:
Currently the only possible  way to use context metadata is adding it to the schema with Ecto.put_meta/2. To be able to set a context on schema definition just as its possible to set a prefix with @schema_prefix would make context way more useful, exposing the set context with __schema__/1 would be nice too. Is there anything against doing that? 

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/c90c050c-4cb0-47bf-9cc0-226f466d062fn%40googlegroups.com.

cevado

unread,
Jul 6, 2021, 5:18:16 PM7/6/21
to elixir-ecto
I'm currently working on a library to use ecto schemas to describe API interactions. I'd like to use context metadata for some of the library internals.
Since it's something that is only used at the adapters level and this library would work like an adapter, I think it fits the purpouse.
The library in particular is that one:
https://github.com/fcevado/ecto_api

José Valim

unread,
Jul 6, 2021, 5:25:12 PM7/6/21
to elixi...@googlegroups.com
Yup, looks reasonable to me!

cevado

unread,
Jul 6, 2021, 5:32:01 PM7/6/21
to elixir-ecto
I'll work on a PR for this.

cevado

unread,
Jul 6, 2021, 6:03:29 PM7/6/21
to elixir-ecto
PR is open.
Reply all
Reply to author
Forward
0 new messages