Hi, i’m creating a query via realm android, but the only one result that is fetched is collection.count(). Trying to retrieve data or a list of data return always null.
This is the code that query database
CoroutineScope(Dispatchers.IO).launch {
val res: Deferred<Tenant> = async {
val mongoDatabase = loginRealm().getMongoClient("mongodb-atlas")
.getDatabase(BuildConfig.MONGODB_DATABASE)
val codecRegistry = CodecRegistries.fromRegistries(
AppConfiguration.DEFAULT_BSON_CODEC_REGISTRY,
CodecRegistries.fromProviders(
PojoCodecProvider.builder().automatic(true).build()
)
)
val collection = mongoDatabase.getCollection(
Tenant::class.java.simpleName,
Tenant::class.java
).withCodecRegistry(codecRegistry)
// return numbers of documents. Ok
val count = collection.count().get()
Log.d("REALM_COUNT", count.toString())
// Return null. Not ok
collection.findOne(Document("_id", id)).get()
}
This is realm backend log:
{
"name": "findOne",
"arguments": [
{
"database": "softchef",
"collection": "Tenant",
"query": {
"_id": "1"
}
}
],
"service": "mongodb-atlas"
}
Function Call Location:
US-VA
Compute Used:
117602148 bytes•ms
Remote IP Address:
179.181.116.115
SDK:
android v10.10.0
Platform Version:
11
Rule Performance Metrics:
{
"namespacesMetrics": {
"softchef.Tenant": {
"roles": {},
"noMatchingRole": 0
}
}
}
No error messages, nor return information.
Any help welcome…