Github user michellephung commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/434#issuecomment-106874225
  
    @wadsashika 
    
    Regarding the `parse` function,
    
    One part of the greatness of Couchdb that that all of it's responses come 
back in JSON format, which a format that is really fantastic compared to other 
data structures out there. 
    
    What backbone does automatically with the CouchDB responses would be 
separate each key and value and make them easy to use in other parts of the 
code via, models and collections. The parse function is kind of like a 
interceptor, happening before backbone separates the response into collections 
and models. So within the body of the `parse` function, you can change what 
goes into the collection/model before you use collection/models in other parts 
of the program. 
    
    For example, 
    Lets say I have stored in CouchDB a database which is full of people's 
first and last names, and they were compiled from a regular users that put in 
their own names, etc. So the names are in the database all kinds of wacky, with 
wiErD caPitaLizations, or all lower-case, or sometimes they've uploaded symbols 
 :fish:  instead of real names. So the database has all wacky inconsistent 
names, and so in `parse`, what you can do is: before those names go into the 
models/collections, you can sanitize them so that they are normal names, ie 
first letter capital, following letters in lowercase. 
    
    So what I've done with the parse function in active tasks is put all the 
active tasks into an array, since we're moving away from 
backbone/models/collections. Then I use the array and do whatever I want with 
the data as usual. I was thinking, 'one day soon, there will be no more 
collections/models.' Although, probably a more accurate representation would 
keep the JSON response in an object instead of an array. 
    
    It's your choice to use an object or an array. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to