On the Rails app, we can print the record count of a database table by a command like this: rails r "puts User.count" With my knowledge, if we want the same thing on the Phoenix/Ecto environment, we should run such a command: mix run -e "IO.puts SampleApp.Repo.aggregate(SampleApp.User, :count, :id)" That is OK, but is too lengthy for a daily usage. Is there any shorter way?
# = name = "TEST" User |> where([u], u.name == ^name) |> Repo.all() # SELECT u0.`id`, u0.`name`, u0.`age`, u0.`inserted_at`, u0.`updated_at` FROM `users` AS u0 WHERE (u0.`name` = ?) # ["TEST"] # != name = "TEST" User |> where([u], u.name != ^name) |> Repo.all() # SELECT u0.`id`, u0.`name`, u0.`age`, u0.`inserted_at`, u0.`updated_at` FROM `users` AS u0 WHERE (u0.`name` != ?) # ["TEST"] # > age = 20
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く