Skip to content

Commit

Permalink
invert logic for isLatest in Object search
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Oct 16, 2023
1 parent bfd2286 commit b88a313
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/src/db/models/tables/objectModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ class ObjectModel extends Timestamps(Model) {

query.withGraphJoined('version');
if (value) {
// join on version where isLatest = true
query.modifyGraph('version', builder => {
builder
.select('version.*')
.where('version.isLatest', value);
});
} else {
// TODO: Consider modifying graph to join on all versions except latest
// join on ALL versions where isLatest = false
const subquery = Version.query()
.select('version.id')
.where('version.isLatest', true);
query.whereNotIn('version.id', builder => {
.where('version.isLatest', false);
query.whereIn('version.id', builder => {
builder.intersect(subquery);
});
}
Expand Down

0 comments on commit b88a313

Please sign in to comment.