couchbaselabs/mobile-travel-sample

Android: It is not clear where "hotels" document comes from? Is it a property of `bookmarkedhotels` document?

hideki opened this issue · 1 comments

  • Develop
    2) The Basics
    • Delete a Document

http://docs-build.sc.couchbase.com:9000/develop/java#/2/1/2

The code below deletes the "hotels" document from the database every time a hotel is unbookmarked.

In addition to deleting the "hotels" document, the unbookmarking process updates the "bookmarkedhotels" document by removing the the hotel Id hotels array.

In Data Modeling section, It seems none of documen types is hotels. It seems hotels is one of the properties of bookmarkedhotels document. So Above sentences do not make sense?


Again, guestDoc.setArray("hotels", hotelIds); is unnecessary

Document guestDoc = database.getDocument("user::guest");
Array hotelIds = guestDoc.getArray("hotels");
for (int i = 0; i < hotelIds.count(); i++) {
    if (hotelIds.getString(i).equals((String) bookmark.get("id"))) {
        hotelIds.remove(i);
    }
}
guestDoc.setArray("hotels", hotelIds); <<<<<<<
try {
    database.save(guestDoc);
} catch (CouchbaseLiteException e) {
    e.printStackTrace();
}
  • The Basics refer to a "hotels" document. It should be "hotel" like in the Data Modeling diagrams. Should also explain the hotel doc is firstly queried on the rest api and then persisted if bookmarked (@jamiltz)
  • Remove unnecessary line (@hideki)