Skip to content

Commit

Permalink
[upload-docs] include imported_date field
Browse files Browse the repository at this point in the history
Closes #34
  • Loading branch information
alxndrsn committed Oct 24, 2017
1 parent 27f26b1 commit 02c97af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-configurer-beta",
"version": "1.6.8",
"version": "1.6.9",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 11 additions & 3 deletions src/fn/upload-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ module.exports = (projectDir, couchUrl) => {
const results = { ok:[], failed:{} };

const process = sets.reduce((promiseChain, docSet) =>
promiseChain.then(() =>
db.bulkDocs(docSet.map(fs.readJson))
promiseChain.then(() => {
const now = new Date().toISOString();
const docs = docSet.map(file => {
const doc = fs.readJson(file);
doc.imported_date = now;
return doc;
});

return db.bulkDocs(docs)
.then(res => {
trace('Uploaded', docSet);
res.forEach(r => {
Expand All @@ -46,7 +53,8 @@ module.exports = (projectDir, couchUrl) => {
results.ok.push(r.id);
}
});
})),
});
}),
Promise.resolve());

return process
Expand Down

0 comments on commit 02c97af

Please sign in to comment.