delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

How to do Querying for when key is inside dictonary #102

Closed prasannakumark closed 8 years ago

prasannakumark commented 8 years ago

Hi All,

I've question about, how to make query when key is inside Hashmap. Let me explain with an example, my document

{ "_id" : "EMBdf4LcYAaEKgPqw", "createdAt" : ISODate("2016-05-30T15:18:02.519Z"), "services" : { "password" : { "bcrypt" : "$2a$10$/xYaxEaD5RTfPJ1v930G9.xd66atXZMRPw1PrcA7ZC2NVqzcEe48G" } }, "username" : "6021000", "emails" : [ { "address" : "zvvxvxv", "verified" : false } ], "profile" : { "address" : [ { "latitude" : "26.588517253293613", "longitude" : "26.588517253293613", "landmark" : "hxbx", "location_address" : "78vzzvzvvzv" } ], "raw_password" : "9898585888", "user_type" : "Customer", "mobile" : "9898585888", "name" : "xvdvv", "alternate_mobile" : [ "8787887878" ], "frequency" : "regular", "user_id" : "HaYNczH3Groustnbn", "otp" : 3357 }, "firstLogin" : false }

but i want to search by using mobile, is that mobile number is same or not. Here my question is key is not a direct key, its inside the dictionary, how i can pass key here or else any other solutions

Query query = MeteorUtility.getMeteor(CreateOrderActivity.this).getDatabase().getCollection("users").whereEqual(fieldName, "7865799747");

please let me know if you need any clarification and information

Thanks prasanna

prasannakumark commented 8 years ago

Hello All,

do we have any possibilities make queries like this. If you guys could not understand the questions please revert me back. But i think it is very important feature i feel.

Thank's prasanna

ocram commented 8 years ago

Thank you very much!

It seems you want to query by profile.mobile, right? At least, that's the syntax you would use in Meteor or MongoDB. It's called "dot notation" [1] [2].

Unfortunately, this is not possible with this library, yet. We had to implement a custom access layer for the database from scratch, so you can't just use everything that works in Meteor. Sorry! But this is definitely something we should support, and I'd suggest we use the same syntax. What do you think?

Today, you can only query by fields on the first level, e.g. username.

So, in the meantime, the advice from https://github.com/delight-im/Android-DDP/issues/94 might be helpful to you. We're closing this issue here because that other issue is about the same thing. Let's track our progress there :)