phoenix-framework

    0熱度

    1回答

    我是Postgresql JSONb和Ecto的新手。我有一個列「配置」,是jsonb的表。我能夠插入,但是當我嘗試從中選擇使用片段函數的條件時,我無法使其工作。下面是示例輸出: iex> Repo.all(from i in Instance, select: i.configuration, where: fragment("?->'testing' LIKE '%hey%'", i.con

    1熱度

    1回答

    例如,我有一個返回json的API客戶端(作爲字符串,未解碼)。目前,我必須做這樣的事情 def show(conn, params) do {:ok, json} = ApiClient.fetch(params["options"]) json conn, Poison.decode!(json) end 如果我避免Poison.decode那麼響應將是一個巨大的字

    0熱度

    1回答

    因此,我想使用存在行爲跟蹤每個用戶的當前房間。問題是如果用戶改變當前房間,我不能/不知道如何更新room_id。 def join("room:" <> room_id, auth_message, socket) do IO.puts "joining room:" <> room_id if authorized?(room_id, socket) do {:ok, assign(socket

    0熱度

    1回答

    如果我GenStage的handle_demand/2方法是這樣的: def handle_demand(demand, _state) when demand > 0 do case Queue.dequeue do nil -> Logger.debug("Queue empty.") {:noreply, [], []} {job, up

    1熱度

    1回答

    在我的Phoenix應用程序中,我試圖將事件記錄插入到數據庫中,該數據庫的字段爲start_time和end_time - 日期時間數據已經轉換爲ISO字符串格式在客戶端,並作爲JSON數據傳遞給Phoenix API,但是當我嘗試插入數據時,這會導致一些麻煩 - 模型期望這些值爲:utc_datetime,因此我需要將它們轉換 - 我通讀文檔,但我仍然不知道... 首先,這裏的模型架構: @pr

    0熱度

    1回答

    雖然Elixir鼓勵我們不要使用try/catch塊,但有時候需要它們。在我寫的一個應用程序中,我有以下try/catch的工作。 try do message = GenServer.call(via, :get_messages) {:ok, message} catch :exit, _ -> {:error, "Process uuid no longer

    2熱度

    1回答

    我有以下的(人爲)代碼: dbconn # this var holds the database connection get_from_cache("missing_key") defp get_from_cache(key) do Cachex.get(:my_cache, key, fallback: &from_db/1) end defp from_db(key)

    2熱度

    1回答

    我有以下函數定義,我試圖找到一種方法來簡化參數,使它們都是統一的。 def update_user(%User{} = user, %{password: _} = attrs) do attrs = Map.put(attrs, :password_reset_token, nil) update_user(user, attrs, &User.password_change

    1熱度

    1回答

    我已經創建了一些phoenix應用程序,並且所有似乎默認情況下都不接受https請求。我收到錯誤[error] Cowboy returned 400 and there are no headers in the connection.。 Http請求按預期返回數據。

    0熱度

    1回答

    使用外生V2.2.6多個協會,鳳凰1.3 我在其中一個用戶可以創建職位的場景,然後其他用戶可以像帖子。用戶通過創建與帖子建立一對多關係,並通過鏈接表與喜歡建立多對多關係。 設置: mix phx.gen.json Account User users name:string mix phx.gen.json Content Post posts title:string content:text