我在Phoenix控制器中查詢了一個學生列表,並且列表中的每一行都在其id上加入了bloodgroup並獲取血型組名稱。我想在我生成的一個eex模板中顯示它,但是出現錯誤。 這裏的學生架構: schema "students" do
field :firstname, :string
field :lastname, :string
field :birthday,
假設NULL值,我們有一個空的列permission_set_id,這是一個外鍵稱爲permission_sets另一個表稱爲users表,其中的Ecto.Schema.belongs_to/3(文檔here)宏來實現的。我需要取消其場這樣的查詢: query = from u in User,
where: u.id == ^user_id
case Repo.update_al
讓說我有一個模型,像: defmodule User do
use MyApp.Web, :model
schema "users" do
field :email, :string
field :first_name, :string
belongs_to :role, Role
has_many :comments, Commen
我有一個與has_many關聯的ecto模型。我想用默認的查詢來定義這個關聯。 像 defmodule MyApp.User do
use MyApp.Web, :model
schema "users" do
has_many :comments, MyApp.Comment
end
end
我想獲取不屬於deleted評論(刪除是MyApp.Co
我有更多的noob問題。當我做類似 case MyRepo.insert %Post{title: "Ecto is great"} do
{:ok, struct} -> # Inserted with success
{:error, changeset} -> # Something went wrong
end
回購如何知道數據庫中的哪個表使用?
我試圖在窗體中顯示一些相關數據。我有一個學生架構 schema "students" do
field :firstname, :string
field :lastname, :string
field :birthday, Ecto.Date
field :joined_on, Ecto.Date
field :gender, :string
Ecto documentation顯示如何執行插值。但我在查詢中需要動態字段。我有幾十個領域,併爲他們每個人寫查詢似乎不具有凝聚力。 defmodule Hedone.SearchController do
use Hedone.Web, :controller
alias Hedone.User
def idade(conn, %{"idade+" => ma