My schema looks like that :
Block: key_point
who has two fields title
(Single-line string) and image
(Single asset)
Model: runtime
who has two fields slug
and key_points
(Modular content) that only accept one type of Block (key_point)
client = Dato::Site::Client.new(ENV["DATO_API_TOKEN_RW"])
runtime = client.items.all(
nested: true,
filter: {
type: "runtime",
fields: {
slug: {eq: "my-slug"},
},
},
).first
key_points = runtime["key_points"]
puts key_points["en"].first
# {"id"=>"10622761", "type"=>"item", "attributes"=>{"title"=>"Toto"}, "relationships"=>{"item_type"=>{"data"=>{"id"=>"401631", "type"=>"item_type"}}}}
key_point_id = key_points["en"].first["id"]
key_point = client.items.find(key_point_id, nested: "true")
puts key_point
# {"id"=>"10622761",
# "meta"=>
# {"created_at"=>"2020-11-14T17:48:25.141+01:00",
# "updated_at"=>"2020-11-14T17:48:25.144+01:00",
# "published_at"=>"2020-11-14T17:48:25.880+01:00",
# "publication_scheduled_at"=>nil,
# "unpublishing_scheduled_at"=>nil,
# "first_published_at"=>"2020-11-14T17:48:25.880+01:00",
# "is_valid"=>true,
# "status"=>"published",
# "current_version"=>"21006016",
# "stage"=>nil},
# "title"=>"Toto",
# "updated_at"=>"2020-11-14T17:48:25.144+01:00",
# "created_at"=>"2020-11-14T17:48:25.141+01:00",
# "item_type"=>"401631"}
I don’t have any reference to my image
field, is it a bug ? Should I do something differently?
Thanks for the help
Jean