나는 지금 벽을 치고있다. 나는 Elixir와 Ecto와 함께 일하고 있는데 Datetime을 가진 테이블과 컬럼이있는 테이블을 가지고있다. 2017-11-16 16:02:01
2017-11-23 09:00:07
2017-11-27 13:19:58
2017-12-05 07:48:42
는 내가 뭘 원하는 것은 대신 날짜의 시간에 따라 정렬이 테이블
나는이 지시에 따라 many_to_many 연관을 생성하기 위해 http://blog.roundingpegs.com/an-example-of-many-to-many-associations-in-ecto-and-phoenix/ 지시를 따랐다. 그러나 many_to_many 테이블에 일부 필드가 필요합니다. users_organizations에는 필자의 경우
작업 모델 schema "jobs" do
belongs_to :status, Test.JobStatus,
foreign_key: :status_id,
references: :id,
type: :string
timestamps()
end
와 나는이 상태 모델을 가지고 : 나는 그것하지 PARAMS의 경우 (기
그래서 Bindingless 작업에 대한 ecto 설명서를 읽었습니다. 동적 값에 유용합니다. from Post,
where: [category: "fresh and new"],
order_by: [desc: :published_at],
select: [:id, :title, :body]
그럼 내 질문은. select: max
모델의 타임 스탬프를 기반으로 날짜 범위를 쿼리해야합니다. 내가 지금까지 시도 포스트 그레스의 날짜가 날짜의 형태로, 예를 들어,이다 그러나 str="2017-12-18"
{:ok, ed}=Ecto.Date.cast(str)
ed= ed |> Ecto.Date.from_erl |> NaiveDate.from_erl!
Repo.all(from l in
최근 피닉스와 협력하기 시작했습니다. 사실은 보통 SQL 데이터베이스가없는 상태입니다. 나는 협회를 통합하기 위해 고전적인 블로그 작업을하고 있습니다. 나는 기본적인 협회 만들었습니다 schema "categories" do
field :category_name, :string
field :logo, :string
has_many
내 블로그 앱에는 Comment이 많은 Post 모델이 있습니다. schema "post" do
field :title, :string
field :content, :string
belongs_to :owner, MyApp.Accounts.User, foreign_key: :owner_id
has_many :comme
내 블로그 앱에는 다른 사람들의 게시물을 복사하여 자신의 것으로 호스트 할 수있는 기능이 있습니다. Post은 소유자와 연결되어 있습니다. schema "posts" do
field :title, :string
field :content, :string
belongs_to :owner, MyApp.Accounts.User, fo
나는 ecto 2.2.6을 사용하고 있습니다. 저는 외부로 가입하려고합니다. 처음에는 List를 사용하여 단일 테이블로 선택 값을 반환했습니다. (1) 다음으로 테이블 조인 때문에 선택 값을 반환하기 위해 Map을 사용했습니다. (2) Repo.all(from m in "members",
left_join: g in "groups",
내 Foo 스키마는 has_many 스키마 Bar입니다. schema "foos" do
field :content, :string
has_many :bars, MyApp.Content.Bar, foreign_key: :foo_id
end
schema "bars" do
field :content, :string