-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove formatting data function * add default properties in document for new saves * make comment more clear * cleanup * add migration --------- Co-authored-by: Ciaran Schutte <[email protected]>
- Loading branch information
1 parent
877d6e4
commit f16c900
Showing
4 changed files
with
59 additions
and
41 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
migrations/20240209102734-413-add-default-exception-properties.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* ensure that all property entity exceptions are defined with default values ie. [] | ||
*/ | ||
const defaults = { | ||
follow_up: [], | ||
treatment: [], | ||
specimen: [], | ||
}; | ||
|
||
module.exports = { | ||
async up(db, client) { | ||
try { | ||
const exceptions = await db | ||
.collection('entityexceptions') | ||
.find() | ||
.toArray(); | ||
|
||
exceptions.forEach((exception) => { | ||
const _id = exception._id; | ||
const update = { ...defaults, ...exception }; | ||
|
||
db.collection('entityexceptions').updateOne( | ||
{ _id }, | ||
{ | ||
$set: update, | ||
}, | ||
); | ||
}); | ||
} catch (e) { | ||
console.error('migration up failed', err); | ||
throw err; | ||
} | ||
}, | ||
|
||
async down(db, client) { | ||
// no action needed | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters