简体   繁体   中英

How to batch insert with quill dynamic queries?

I'm trying to use Quill dynamic queries to perform batch insert

In non-dynamic api I would've used:

db.run(quote {
liftQuery(myCollection).foreach(data => querySchema[MyDBClass]("table").insert(data))
})

I've tried doing the same for dynamic query:

db.run({
liftQuery(myCollection).foreach(data => dynamicQuerySchema[MyDBClass](tableNameVar).insertValue(data))
})

But I get the following error:

No implicits found for parameter unquote: DynamicInsert[MyDBClass] => A_

Am I using the API correctly? any help would be appreciated

The work-around is:

val dynamicSchema = context.dynamicQuerySchema[MyDBClass](tableNameVar)

context.transaction {
      myCollection.foreach { p =>
        context.run(dynamicSchema.insertValue(p))
      }
    }

For cassandra use without transaction

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM