How to pull replicate only one channel?
Replication.channels property. Set this to an array of channel names you want to pull.
How to pull newest post first
Replication doesn’t really have a deterministic order. It’s basically in forward order of mod date (i.e. least recently modified docs first) but everything’s being downloaded asynchronously so they may not end up being added to the db in a predictable order.
so it will be replicated back to the device where post document is purged.How to avoid this?
You can’t really avoid it. You could work around it by keeping a list of docIDs that you’ve purged, and re-purging them if they reappear.
BTW, about “Same post is liked by other user then this post document is updated”: That’s generally not a good way to do it. It’s going to create a lot of potential conflicts — think if dozens of users like a post at almost the same time, and each tries to push its change to the post doc. Instead, a Like can be a separate doc that refers to the post. Then you use a view to find/count the likes for posts.
How to fetch posts by most likes
You can use a view with a reduce function and grouping, to get a mapping from postID to like-count. Then you can sort that by like-count.
Is there any cb lite api function to remove user from channel
Use a PUT to update the user info (
/db/_user/username) via the admin REST API. But it’s more common to have documents grant channel access to users; then updating that doc can remove the grant.