Sure , here is the map function.
function (doc) {
// Get Products AND Categories by levelIdFather
if (doc.shopCode && doc.levelIdFather) {
if (doc.levelId) { // Category
emit([doc.shopCode, doc.levelIdFather], {name : doc.name, levelId : doc.levelId});
} else if (doc.sku) { // Product
if (typeof doc.levelIdFather == "object") {
for (var key in doc.levelIdFather) {
emit([doc.shopCode, key], {sku : doc.sku, name : doc.name, packaging : doc.packaging, priceOfUnit : doc.priceOfUnit, unitPrice : doc.unitPrice, base_url : doc.base_url, imageNumber : doc.imageNumber});
}
} else {
emit([doc.shopCode, doc.levelIdFather], {sku : doc.sku, name : doc.name, packaging : doc.packaging, priceOfUnit : doc.priceOfUnit, unitPrice : doc.unitPrice, base_url : doc.base_url, imageNumber : doc.imageNumber});
}
}
}
/*try {
emit(doc._id, doc._rev);
} catch (err) {
log(err.message);
}*/
}
We can give you an access to a sync url where you will find a database with all the documents if you want to reproduce on iOS.
Also find below a sample document
{
“_id”: “product_42_3056440031637”,
"_rev": “2-64d43bb2dd4e8ae80e20253c894775ea”,
“shopCode”: “42”,
“sku”: “3056440031637”,
“levelIdFather”: “48196”,
“name”: “Biscuits chocolat noir Pépito”,
“packaging”: “les 2 paquets de 200 g”,
“priceOfUnit”: “4.05”,
“unitPrice”: “1.62”,
“base_url”: “http://XXXXX.fr/”,
“imageNumber”: “4077713”,
"~c8oAcl": “42”
}