简体   繁体   English

如何在 KMongo 协程客户端中使用 GRIDFSBuckets

[英]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.databaseCoroutineDatabase获取MongoDatabase实例。 In your case that would be db.database在您的情况下,这将是db.database

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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