Craft your domain-specific query language with NimbleParsec and Ecto - R. Binetti | Code BEAM Europe

Ғылым және технология

"✨This talk was recorded at Code BEAM Europe 2023. If you're curious about our upcoming event, check codebebeameurope.com ✨
Imagine you want to ask your API ""List all devices which are not located in Europe and are currently connected or are either tagged 'maintenance' or 'retired'"". Expressing this kind of selection with query parameters quickly becomes unwieldy, and even a more structured query language like GraphQL can feel clunky to express this, especially if the target user is not a technical one.
Ideally, we'd want users to be able to write something like:
(not attributes[""continent""] == ""EU"") and (connected or (""maintenance"" in tags or ""retired"" in tags))
In this talk I will show you how this can be achieved with the power of Elixir, NimbleParsec and Ecto.
We will use NimbleParsec to parse the domain-specific language into an Abstract Syntax Tree represented using Elixir structs, and then we will traverse that AST to produce a valid query using the power of Ecto dynamic queries.
Let's keep in touch! Follow us on:
💥 Twitter: / codebeamio
💥 Facebook: / codesyncglobal
💥 Linkedin: / code-sync
💥 Mastodon: genserver.social/codesync "

Пікірлер: 3

  • @bjrnhjjakobsen2174
    @bjrnhjjakobsen217420 күн бұрын

    Very cool stuff 🙏

  • @xmentero
    @xmentero20 күн бұрын

    This was a really cool talk. I really enjoyed it

Келесі