Skip to content

Instantly share code, notes, and snippets.

@omegahm
Created June 10, 2015 11:52
Show Gist options
  • Save omegahm/389b00d3f547f21e7b76 to your computer and use it in GitHub Desktop.
Save omegahm/389b00d3f547f21e7b76 to your computer and use it in GitHub Desktop.
function(doc) {
doc.postal_districts.forEach(function(pd) {
pd.postal_codes.forEach(function(pc) {
emit(pc.postal_code, {
postal_name: pc.name,
postal_code: pc.postal_code,
type: pc.type,
postal_district_id: pd.id,
slug: pd.slug
})
});
});
}
function(doc) {
pds = doc.postal_districts
for(i=0;i<pds.length;i++){
pcs = pds[i].postal_codes
for(j=0;j<pcs.length;j++){
data = { postal_name: pcs[j].postal_name, postal_code: pcs[j].postal_code, type: pcs[j].type, postal_district_id: pds[i].id}
emit(pcs[j].postal_code, data );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment