ecto Questions

2

Solved

I'm trying to use Geo library to store Geo.Point via Phoenix model changeset. My params are: {coordinates: [49.44, 17.87]} or more prefer would be {coordinates: {latitude: 49.44, longitude: 17.87}}...
Salesroom asked 23/11, 2015 at 12:7

3

I'm currently working on a Phoenix project where I'm unsatisfied with the way I'm calling fields in the templates. The schema is currently defmodule MyApp.Car do use MyApp.Web, :model schema "c...
Pyrostat asked 13/4, 2016 at 22:43

5

Solved

I am beginning my Elixir/Phoenix journey and having some trouble with my postgres connection. When I start up my server I get: $ mix phoenix.server [error] Postgrex.Protocol (#PID<0.214.0&gt...
Mileage asked 23/8, 2016 at 2:29

2

Solved

I have a raw sql query which returns a datetime field and I want to return a json with those results. If I put the return value I get a complain: (Poison.EncodeError) unable to encode value: {{20...
Kimbro asked 21/3, 2017 at 22:34

1

Solved

So I'm having trouble using order_by in my query with preload function. Usually I use order_by like in this list_member function list_member def list_members() do query = from( p in Member, s...
Yardmaster asked 20/3, 2019 at 1:24

1

Solved

I'm trying to create a mix task for automation some scaffolding and I want to get a list of all module names in the application which have schema and embed schema implementations. Eventually I'd li...
Kandykane asked 14/3, 2019 at 9:45

1

Solved

I'm trying to create a migration using the command mix ecto.gen.migration <migration_name> and I'm getting the error: Cannot run task "ecto.gen.migration" from umbrella application Why I'm...
Coot asked 12/3, 2019 at 20:10

1

Solved

It's clear how to preload associations in Ecto 1-2 levels deep, such as post and comments to it. I have an Address, and Address belongs_to a Street, and Street belongs_to a City, and City belongs...
Proust asked 20/2, 2019 at 22:32

2

Solved

I am wondering if it is possible to combine two queries together in ecto. I would like to create a function which takes an ecto query and modifies it depending on the case. For example, let's ima...
Mooney asked 12/2, 2019 at 18:38

3

Solved

I recently upgraded my phoenix project to Ecto 2.0.2. I have some code that is using Task.Supervisor.async_nolink to make some updates to the db on its own thread. I am getting the following error ...
Hephzibah asked 12/7, 2016 at 17:38

2

Solved

I'm following the "Programming Phoenix" book by Chris McCord and in Chapter 6, a relationship is created between a User and a Video. When trying to run it with mix phoenix.server, the following er...
Recognize asked 4/8, 2016 at 14:29

2

Solved

How do I check if an id exists in the database? def get_user!(id), do: Repo.get!(User, id) get_user!(id) can be used to get the user, is there a way to check if id exists? I want something like...
Township asked 5/6, 2018 at 10:4

2

Solved

Changing the association of a given child from parent_a to parent_b via parent_id in params leaves a stale record.parent object. e.g. (assume params matches %{child: %{id: '1', parent_id: '6'}}) ...
Uropygium asked 22/1, 2016 at 11:21

2

Solved

I'm trying to build a function that searches for a term in a field of a given table in a query. For a query like initial_query = Answer |> join(:left, [a], q in assoc(a, :question), as: :qu...
Garment asked 31/1, 2019 at 21:36

2

Solved

I want to get the current date-time stamp in Phoenix/Elixir without a third-party library. Or simply, I want something like DateTime.now(). How can I do that?
Threedimensional asked 5/9, 2016 at 13:28

3

I have an existing project built with default settings. Now I see that I dont really need Ecto for anything. I just want to remove all DB related events from the code. Can someone guide me throug...
Cydnus asked 21/7, 2016 at 7:1

2

Solved

What is Phoenix's equivalent of Rails'? rake db:migrate:down VERSION=20100905201547
Trophozoite asked 15/1, 2017 at 13:31

1

Interesting issue I'm getting. I have a test that deals with file uploading using arc-ecto. In the uploader module I override storage_dir function. There I do a database call to fetch id of the par...
Denumerable asked 29/3, 2017 at 22:43

1

I am defining a schema for my user and role models in Phoenix app. Role has_many users and user belongs_to a role. It seems like there are 3 different on_delete: options: nilify_all, nothing(defaul...
Gainsborough asked 31/10, 2018 at 22:27

4

Solved

I am not able to create my Phoenix project. Would love some advice on how to fix it. Setup details: Ubuntu 16.04.4 LTS Erlang/OTP 21 [erts-10.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-t...
Riff asked 29/10, 2018 at 12:40

0

I would like to run my Ecto.Query.from on a specific partition of a partitioned MySQL table. Example table: CREATE TABLE `dogs` ( `dog_id` bigint(20) unsigned NOT NULL, ... PRIMARY KEY (`dog_i...
Venturous asked 25/10, 2018 at 1:33

1

Solved

Consider the following schema: defmodule EctoBug.Post do use Ecto.Schema import Ecto.Changeset schema "posts" do field :title, :string, default: "test" timestamps() end def changeset(pos...
Metzgar asked 13/10, 2018 at 13:3

3

Solved

Since inserted_at and updated_at can not be null this won't work: def change do alter table(:channels) do timestamps end end ** (Postgrex.Error) ERROR (not_null_violation): column "inserted_a...
Rhododendron asked 2/3, 2016 at 10:22

1

Solved

I am attempting use Ecto Repo.get_by with multiple clauses, and I'm having trouble finding syntax examples. I need to query where either or 2 fields in the DB match, so an 'or' condition between th...
Grownup asked 31/8, 2018 at 11:29

3

In Rails, if I have the following setup: class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post def self.approved where(approved: tr...
Electrocardiograph asked 1/6, 2015 at 22:20

© 2022 - 2024 — McMap. All rights reserved.