[英]How to use GRIDFSBuckets with KMongo coroutine client
I am trying to use GRIDFSBuckets in ktor to upload files.我正在尝试在 ktor 中使用 GRIDFSBuckets 来上传文件。 I am using KMongo coroutine extension to create my MongoDB client.
我正在使用 KMongo 协程扩展来创建我的 MongoDB 客户端。 When calling GRIDFSBucket.create().
调用 GRIDFSBucket.create() 时。 Its parameters need a MongoDatabase and bucketName.
它的参数需要一个 MongoDatabase 和 bucketName。 This is fine but KMongo coroutines creates a
CoroutineDatabase
not a MongoDatabase that is needed.这很好,但是 KMongo 协程创建了一个
CoroutineDatabase
而不是需要的 MongoDatabase。 Is there anyway around this?有没有办法解决?
You can get a MongoDatabase
instance from CoroutineDatabase
by calling CoroutineDatabase.database
.您可以通过调用
CoroutineDatabase.database
从CoroutineDatabase
获取MongoDatabase
实例。 In your case that would be db.database
在您的情况下,这将是
db.database
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.