Exclude document from list

46 views
Skip to first unread message

Karel-Jan Van Haute

unread,
Nov 27, 2014, 4:50:14 PM11/27/14
to mobile-c...@googlegroups.com
How can I exclude one document from a list of documents? 

ajres

unread,
Nov 28, 2014, 1:30:38 PM11/28/14
to mobile-c...@googlegroups.com
Were going to need a bit more context to help you with this.

Can you let us know the environment your working in and what your trying to achieve.

A code snippet would be good to.

Andy

Karel-Jan Van Haute

unread,
Nov 28, 2014, 2:09:00 PM11/28/14
to mobile-c...@googlegroups.com
Hey Andy

I'm making an application with cblite in IOS using Swift. In my app you can select an item from a list (CBLTable) and than you can select a second item from the same list. But you must not be able to select the first item for a second time. So the second time I want to exclude the first item from the list. 

I hope this make sense.

Jens Alfke

unread,
Dec 1, 2014, 11:39:41 AM12/1/14
to mobile-c...@googlegroups.com

On Nov 28, 2014, at 11:09 AM, Karel-Jan Van Haute <kare...@gmail.com> wrote:

I'm making an application with cblite in IOS using Swift. In my app you can select an item from a list (CBLTable) and than you can select a second item from the same list. But you must not be able to select the first item for a second time. So the second time I want to exclude the first item from the list. 

Sounds like you'll need to manage the data source yourself. CBLUITableSource is just a convenience for the common task of displaying a view as a table — it's not intended to do everything you could possibly want to do. You may want to start by copying the source code (and renaming the class) and then adapting it to do what you need.

—Jens
Message has been deleted

CouchbaseLover

unread,
Dec 2, 2014, 3:00:31 AM12/2/14
to mobile-c...@googlegroups.com
It's as easy as making a MapReduce that has !"document.selected = true" for example.
      "      if (![doc[VanHautesDocumentisEqualToString:selected]) "

Regards,
CouchbaseLover 

Karel-Jan Van Haute

unread,
Dec 2, 2014, 3:35:26 AM12/2/14
to mobile-c...@googlegroups.com
So you alter a parameter selected on the object? Or where does the selected come from?

Jens Alfke

unread,
Dec 2, 2014, 11:43:17 AM12/2/14
to mobile-c...@googlegroups.com

On Dec 1, 2014, at 11:59 PM, CouchbaseLover <sharess...@gmail.com> wrote:

It's as easy as making a MapReduce that has !"document.selected = true" for example.
      "      if (![doc[VanHautesDocument] isEqualToString:selected]) "


Don't do that. You really don't want to alter the document every time the user selects it in a list. That will generate a lot of unnecessary indexing and replication — consider how many times documents will get sent over the network if you have X number of users selecting documents every Y seconds…

—Jens

CouchbaseLover

unread,
Dec 3, 2014, 5:06:02 AM12/3/14
to mobile-c...@googlegroups.com
Don't do that. You really don't want to alter the document every time the user selects it in a list. That will generate a lot of unnecessary indexing and replication — consider how many times documents will get sent over the network if you have X number of users selecting documents every Y seconds…

—Jens

First off sorry for the typo, it should be "== true". I don't understand what you are saying Jens, you have a pretty similar example in ToDoLite. If you select a task, you create a new revision with "the task is done" and you get a checkmark on the task UI wise. I agree that ToDoLite is not as data heavy like "Karel's example" due to that you only do "unnecessary indexing and replication" when the task is complete instead of "Karel's example" where it would literally be all the time.

--CouchbaseLover
 

Jens Alfke

unread,
Dec 3, 2014, 11:57:29 AM12/3/14
to mobile-c...@googlegroups.com

On Dec 3, 2014, at 2:06 AM, CouchbaseLover <sharess...@gmail.com> wrote:

First off sorry for the typo, it should be "== true". I don't understand what you are saying Jens, you have a pretty similar example in ToDoLite. If you select a task, you create a new revision with "the task is done" and you get a checkmark on the task UI wise.

Well, in ToDoLite selecting (tapping) a task causes a persistent change in its state, i.e. it's checked off as completed. In Karel-Jan's app, as he describes it, it doesn't sound like the selection is a persistent state, but just part of a UI for choosing some items to operate on. But rereading his post, that's unclear, so maybe it's just my interpretation. 

My point (whether or not it's relevant in this case) is that you shouldn't change a document as a result of a temporary/local condition, only for something that's truly persistent that should be synced.

—Jens
Reply all
Reply to author
Forward
0 new messages