Should the parition id be same for all the users in table ?
I tested it, if the partition id value is same i am getting the list of users which is what i want.
If the partition id value is different i am not receveing any data.
You’ll need to balance what you want from queries with security of your users. That means if you want to be able to search for something within a grouping of data, that data needs to have the same partition key.
However, you won’t want to expose all user data to all other users so one option is to somewhat denormalize the data and have private user data, where each users data has the users uid as it’s partition key and then data you want to expose (search) (which is public or duplicated data ) where they all share the same key.
In essence you’d have a User object with private user data
User: Object {
partitionKey is this users uid
phone_number
address
other private data
}
then you would have a public user object where all of the objects share the same partition key
Public_User: Object {
partitionKey: public_users
user_id is this users uid
name
favorite food
other publicly accessable data
}
That way a user has their own data that only they can access, but then when you need to query across users for say, all users that love pizza, the query is run against the public_users partition key (Realm).