Slick - 如何在没有主键的情况下插入 table

Slick - How to insert into table with no primaryKeys

我有一个没有主键的 table。我怎样才能将数据插入其中。当我有一个带主键的 table 时,我可以执行 insertOrUpdate(...) 但我没有看到仅用于插入的方法。

这是我用主键为 table 所做的:

db.run(table.insertOrUpdate(colorEntity))

您可以使用 += 插入一行:

db.run(table += colorEntity)

要批量插入多行,使用++=:

val colorEntities: Seq[Color] = Seq(...)
db.run(table ++= colorEntities)