我有下表(最大记录数999)我用于查找:
CREATE TABLE lga
(
lgacode character varying(3) NOT NULL DEFAULT '000'::character varying,
lganame character varying(32) NOT NULL,
CONSTRAINT pk_lga PRIMARY KEY (lganame),
CONSTRAINT uk_lga UNIQUE (lgacode)
);
使用Anorm,我可以轻松获得lgas
类型的结果列表List[models.LgaTable]
如何将此结果列表添加到List[Tuple2[String,String]]
形式?
我搜索了Stack Overflow并找到了一些接近的东西([链接] http://stackoverflow.com/questions/4927260/filling-a-scala-immutable-map-from-a-database-table)但这包含{{1}同时,我对此感到厌恶,我只需要一些简单的东西。谢谢
答案 0 :(得分:0)
只需在结果上调用地图:
val lgas: List[models.LgaTable] = ...
val lgas_tupled = lags.map(row => (row.lgacode, lganame))