Skip to content

Instantly share code, notes, and snippets.

@ronycohen
Created April 7, 2015 14:12
Show Gist options
  • Save ronycohen/f74d006c5ccbd4fe46b6 to your computer and use it in GitHub Desktop.
Save ronycohen/f74d006c5ccbd4fe46b6 to your computer and use it in GitHub Desktop.
relational pouch - use of BulkDocs from a JSON.
multiSave : function(json, type){
console.info("multiSave", type);
json.map(function(obj,i){
console.debug(obj, i);
obj._id = factory.db.rel.makeDocID({ "type": type, "id": i+1 });
});
factory.db.bulkDocs(json).then(function (result) {
console.debug("load ok", result);
// handle result
}).catch(function (err) {
console.error(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment