Skip to content

Instantly share code, notes, and snippets.

@andreaseriksson
Created December 25, 2015 14:20
Show Gist options
  • Save andreaseriksson/57e82a8ead26c6091fb6 to your computer and use it in GitHub Desktop.
Save andreaseriksson/57e82a8ead26c6091fb6 to your computer and use it in GitHub Desktop.
Ecto queries
alias FlowCreatorTest.Repo
alias FlowCreatorTest.Customer
import Ecto.Query
Repo.insert(%Customer{email: "[email protected]", customer_fields: %{"foo_id" => "123"} })
Repo.all(from c in Customer, where: fragment("?->>'foo_id' ilike ?", c.customer_fields, "123"))
Repo.one(from c in Customer, where: fragment("?->>? ilike ?", c.customer_fields, "foo_id", "123"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment