2012-12-21 36 views
1

我正在使用boss_db一个小项目,并有一个问题,我没有能够从文档解密。boss_db问题,同时保存记录

这里是我的Postgres数据库表:

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 
); 

这里是我的模型文件:

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

下面是什么在控制台上发生的事情:

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">>}]}} 

回答

1

我道歉,

问题显然在于表中的列ID不存在。但是我问这个问题是因为在其他测试中,我将该列命名为该模型的下划线版本,即如果该模型是客户,那么该列将是customer_id,并且它工作正常。

由于某些原因,仅仅使用名称“id”作为postgres上的列似乎现在工作。

CREATE TABLE recordings (
     id      uuid PRIMARY KEY,  

... );