Now I am confused about how to implement the reduce function so I get messages in which => either from is X OR to is X
Any help on this would be really appreciated.
Seems straightforward now & feels a bit stupid to not be able to figure it out earlier.
Yeah, I have read the existing books on map and reduce for couchdb but none of them deal with complicated cases. They are quite broad.
I have a few follow up questions regarding this architecture -
Q1 Do you happen to have a suggestion on the push notification system I can use for messaging.
I was thinking of having a java server which checks the new messages and sends a push notification accordingly. Having a parameter like isPushed in the message structure or something.
Is this a recommended approach?
Q2 when the user actually opens the app after push notification I assume it would take a few seconds to get these messages. Is there a way to reduce this lag or delay? I know xmpp is pretty fast but it's a whole new implementation. Can we do something to get similar performance?
Q3. The other bit is when a message arrives from a new user who's information isn't available on the local DB. There would also be a lag in pulling this user info. Any suggestions for to make this better?
At the moment I am packing in the name of the user with every message and also thinking of putting in the photo link to amazon in the messages, so I can show something to the user and then when he clicks to see the user details, I show a loading screen if the user details aren't available while I pull it.
Q1 Do you happen to have a suggestion on the push notification system I can use for messaging.
Q2 when the user actually opens the app after push notification I assume it would take a few seconds to get these messages. Is there a way to reduce this lag or delay? I know xmpp is pretty fast but it's a whole new implementation. Can we do something to get similar performance?
Q3. The other bit is when a message arrives from a new user who's information isn't available on the local DB. There would also be a lag in pulling this user info. Any suggestions for to make this better?
I don't think it would be advisable to put chats and user in the same database?
1 more item => Do we push every single message or is there a way to check when the user is online...I mean I could write online and offline in a doc everytime an app opens and closes but seems like that wouldn't be scalable?
User {
Name - xx
{
Type - chat
Sender - xx
To - gg
}
}
Really, is that advisable?
What's the advantage is doing this?
Just put everything in same db but with diff types rather that create separate dbs?
What advantages do I have with this?
Wouldn't this make filtering harder when pulling users based on certain criteria or chats based on which ones are mine?
When you say smart queries to do joins - can you give an example of this? And can I in some way ensure that I always have the document of the user who sent a new chat message.
I.e user doc + chat doc together.