1

I am using boss_db for a small project and are having an issue that I haven't been able to decipher from the documentation.

Here's my Postgres DB table:

CREATE TABLE recordings (
       recording_id       uuid PRIMARY KEY,      
       created            timestamp NOT NULL, 
       cid_name               text DEFAULT '',   
       cid_number         text NOT NULL, 
       destination_number     text NOT NULL,
       file_path              text NOT NULL,
       message_len            integer, 
       archived               boolean DEFAULT false 
  );

Here is my model file:

-module(recording, [Id::uuid(), 
                    Created::datetime(),
                    CidName::string(),
                    CidNumber::string(),
                    DestinationNumber::string(),
                    FilePath::string(),
                    MessageLen::integer(),
                    Archived::boolean()
                   ]).

And here's whats happening on the console:

1> myproto:start().
{ok,<0.34.0>}
2> {ok, recording} = boss_record_compiler:compile("recording.erl").
{ok,recording}
3>  Recording = recording:new(id, {{2012, 12, 20}, {18, 19, 20}}, "", "1002", "1000", "/usr/local/freeswitch/encodings/2012-12-20-13-17-36_1000_1002.ogg", 260, false ).
{recording,id,
           {{2012,12,20},{18,19,20}},
           [],"1002","1000",
           "/usr/local/freeswitch/encodings/2012-12-20-13-17-36_1000_1002.ogg",
           260,false}
4> Recording:save().
{error,{error,error,<<"42703">>,
              <<"column \"id\" of relation \"recordings\" does not exist">>,
              [{position,<<"110">>}]}}
lfurrea
  • 176
  • 1
  • 10

1 Answers1

1

My apologies,

The issue evidently is that the column id does not exist in the table. However I asked the question because on other tests I named the column as the underscore version of the model, i.e if the model was customer then the column would be customer_id and it worked fine.

For some reason just using the name "id" for the column on postgres seems to work now.

CREATE TABLE recordings (
       id                     uuid PRIMARY KEY,      

... );

lfurrea
  • 176
  • 1
  • 10