Skip to content

MongoDB Queries

Mark Robinson edited this page Aug 9, 2017 · 5 revisions

This is a page to design MongoDB queries for #117

Gets, where retrievedFrom.repoUrl and retrievedFrom.path are the same, the last instance of a workflow (random, no real defined order)

db.workflow.aggregate(
  [
    {
      $group: {
        _id: {"retrievedFrom.repoUrl": "$retrievedFrom.repoUrl", "retrievedFrom.path": "$retrievedFrom.path"},
        workflow: { '$last': '$$ROOT' }, 
        versions: { '$addToSet': '$retrievedFrom.branch' }
      }
    }
  ]
)
Clone this wiki locally