I am trying to use boss_db for accessing pgsql. The table should have the column name, id, it should be primary key
The Id type is only be uuid or serial. Is it right?
I want that id is varchar(20), the value of id is decided by the program, not auto decided by DBMS. Is it possible?
create table operators(
id serial primary key, /*I want id is varchar(20), is it possible*/
tag_id varchar(20),
name text,
barcode varchar(20),
tel varchar(12),
mobile varchar(20),
email text,
ldap_user_id varchar(20),
operator_barcode varchar(20)
);
A = operator:new(id,"0102030405060708",
"operator_01","B001","12345678",
"13812345678",
"p001@gmail.com",
"ldap001",
"PB001"),
The follwing codes is from boss_sql_lib.erl
file:
infer_type_from_id(Id) when is_list(Id) ->
[Type, TableId] = re:split(Id, "-", [{return, list}, {parts, 2}]),
TypeAtom = list_to_atom(Type),
IdColumn = proplists:get_value(id, boss_record_lib:database_columns(TypeAtom)),
IdValue = case keytype(Type) of
uuid -> TableId;
serial -> list_to_integer(TableId)
end,
{TypeAtom, boss_record_lib:database_table(TypeAtom), IdColumn, IdValue}.