2
オブジェクトのリストから最初のインデックスオブジェクトを取得します。ここにサンプルオブジェクトがあります:指定されたインデックスオブジェクトの取得中にエラーが発生する
[%VendorModel{__meta__: #Ecto.Schema.Metadata<:loaded>,
cameras: #Ecto.Association.NotLoaded<association :cameras is not loaded>,
config: %{"auth" => %{"basic" => %{"password" => "12345",
"username" => "admin"}},
"snapshots" => %{"h264" => "h264/ch1/main/av_stream",
"jpg" => "Streaming/Channels/1/picture"}}, exid: "ds-2cd2032-i", id: 332,
name: "DS-2CD2032-I",
vendor: #Ecto.Association.NotLoaded<association :vendor is not loaded>,
vendor_id: 6},
%VendorModel{__meta__: #Ecto.Schema.Metadata<:loaded>,
cameras: #Ecto.Association.NotLoaded<association :cameras is not loaded>,
config: %{"auth" => %{"basic" => %{"password" => "12345",
"username" => "admin"}},
"snapshots" => %{"h264" => "h264/ch1/main/av_stream",
"jpg" => "Streaming/Channels/1/picture", "mjpg" => "/",
"mpeg4" => "mpeg4/ch1/main/av_stream"}}, exid: "ds-2cd2612f-i", id: 2911,
name: "DS-2CD2612F-I",
vendor: #Ecto.Association.NotLoaded<association :vendor is not loaded>,
vendor_id: 6},
%VendorModel{__meta__: #Ecto.Schema.Metadata<:loaded>,
cameras: #Ecto.Association.NotLoaded<association :cameras is not loaded>,
config: %{"auth" => %{"basic" => %{"password" => "mehcam",
"username" => "admin"}},
"snapshots" => %{"h264" => "h264/ch1/main/av_stream",
"jpg" => "Streaming/Channels/1/picture", "mjpg" => "/",
"mpeg4" => "mpeg4/ch1/main/av_stream"}}, exid: "ds-2df5274-a", id: 2913,
name: "DS-2DF5274-A",
vendor: #Ecto.Association.NotLoaded<association :vendor is not loaded>,
vendor_id: 6}]
指定されたインデックスオブジェクトを取得します。以下のように:
%VendorModel{__meta__: #Ecto.Schema.Metadata<:loaded>,
cameras: #Ecto.Association.NotLoaded<association :cameras is not loaded>,
config: %{"auth" => %{"basic" => %{"password" => "12345",
"username" => "admin"}},
"snapshots" => %{"h264" => "h264/ch1/main/av_stream",
"jpg" => "Streaming/Channels/1/picture"}}, exid: "ds-2cd2032-i", id: 332,
name: "DS-2CD2032-I",
vendor: #Ecto.Association.NotLoaded<association :vendor is not loaded>,
vendor_id: 6}
私はobjects[0]
を使用してオブジェクトを取得しようとしていますが、それはエラーメッセージの後与えました。エラー:** (ArgumentError) the Access calls for keywords expect the key to be an atom, got: 0
。
この問題を解決するのを手伝ってください。
そして、どのように取得しますアイテム数は? – azharmalik3
http://elixir-lang.org/docs/v1.2/elixir/Enum.html#count/1 – Gazler