Skip to content

Commit

Permalink
Update existing documents with default value for workflow repository
Browse files Browse the repository at this point in the history
  • Loading branch information
SvanBoxel committed Jan 17, 2021
1 parent f359e9d commit aca15d0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/models/runs.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ RunSchema.index(

const Run = mongoose.model<IRun>('Run', RunSchema)

// Update existing document with config.workflows_repository field
Run.update(
{ 'config.workflows_repository': { $exists:false } },
{ $set: {'config': { workflows_repository: '.github'}} },
{ new: true, multi: true },
function(err, numberAffected) {
if (err) return console.error(err);
if (numberAffected?.ok) {
console.log('updated', numberAffected.nModified, 'rows')
}
}
)

export default Run

0 comments on commit aca15d0

Please sign in to comment.