So I'm using Ionic v2 and using Pouch for mobile development using sqlite. Data coming from a REST API which contains something like this:
{
"record-id": "2332255",
"record-name": "record-ABC-XTY",
"record-items": [
{
"item-id": "456454",
"item-name": "item-XADD",
"category": "Cat1",
"subcategory": "Subcat1",
"location": "LocationXYZ",
"owner": "Person1",
"data-rows": [
{
"row-name": "sampleRowName1",
"row-value": "ABC-XASS"
},
{
"row-name": "sampleRowName2",
"row-value": "ABC-XASS"
}
]
},
{
"item-id": "654645",
"item-name": "item-BNSSA",
"category": "Cat2",
"subcategory": "Subcat2",
"location": "LocationABC",
"owner": "Person2",
"data-rows": [
{
"row-name": "sampleRowName1",
"row-value": "ABC-XASS"
},
{
"row-name": "sampleRowName2",
"row-value": "ABC-XASS"
}
]
}
]
}
Now as you can see, the record-items could contain 100,000 items or more (est json size: 32mb). Right now I'm lost on which approach should I take. Optimized data handling is crucial and I don't know what PouchDB approach is better. Here are some of my thoughts.
- Save the whole JSON data as one entry for PouchDB. But I'm worried that it will take up a large memory when retrieved and will make that application slow.
- Chunk the record-items by one pouch entry record and retrieve it individually. I'm not sure if this is better in terms of overall performance but PouchDB record will probably be larger (?).
Also, there will be sorting, fetching all data (only the _ids and few fields just to show a list of all results) and searching.