How to sync docs based on create time?

18 views
Skip to first unread message

atom992

unread,
Jul 13, 2015, 2:10:27 PM7/13/15
to mobile-c...@googlegroups.com
I have a phonegap-plugin based android group chat app, and I want to make user in the same group can sync message.but I only want to sync the message that created time posterior to the time that user join into group.
so In my doc design, I have some docs like:
group doc
{"_id":"group001","type":"grp","members":["user1:20150617","user2:20150620","user3:20150710"]}
which members's field is came from:<user_id>:<join_time(for simplified let's assumption  the time format is YYYYMMDD)>
{message doc}
{"_id":"msg001","type":"msg","create_time":20150618,"user_id":"user1","body":"hello"}
{"_id":"msg002","type":"msg","create_time":20150621,"user_id":"user2","body":"hi"}
{"_id":"msg003","type":"msg","create_time":20150711,"user_id":"user3","body":"nice to meet you"}
what I want is  
for user1 can receive msg001/msg002/msg003;
for user2 can receive msg002/msg003;
for user3 can receive msg003;

I also review the topic and topic, I am consider about is it possible to use webhooks to Implement it? or is there a good way to Implement it?

Jens Alfke

unread,
Jul 13, 2015, 6:33:36 PM7/13/15
to mobile-c...@googlegroups.com

On Jul 13, 2015, at 11:10 AM, atom992 <yangzi...@gmail.com> wrote:

I have a phonegap-plugin based android group chat app, and I want to make user in the same group can sync message.but I only want to sync the message that created time posterior to the time that user join into group.

There’s not currently a good way to do that because the sync criteria rely on relative dates rather than intrinsic properties of the messages.

You’ve already found some threads that discuss similar topics; I think the best answer is still the same as when I replied to one of those.

BTW, I think getting older messages is a feature, not a bug. It’s often very useful to see what was going on in the group before you joined.

I am consider about is it possible to use webhooks to Implement it?

I don’t see how web-hooks would help. The only support Sync Gateway has for those is to call an external API from the sync function to notify it about a document.

—Jens
Reply all
Reply to author
Forward
0 new messages