In a meteor find query how can I compare two fields? I want to do something like the following SQL query.
select * from games g where g.game_minutes > (minutes_since_midnight_now - g.game_duration)
In view of the answers below I did some experimenting along the way to comparing two fields:
this works:
var nextGame = Games.findOne(
{
game_minutes: {$gt: minutesSinceMidnight},
court_id: court,
game_date: {$gt: yesterday}
},
{
sort: {game_minutes: 1}
}
);
this does not work:
var nextGame = Games.findOne(
{
$where: "this.game_minutes" > minutesSinceMidnight,
court_id: court,
game_date: {$gt: yesterday}
},
{
sort: {game_minutes: 1}
}
);
Ultimately I want something like this:
$where: "this.game_minutes" > (minutesSinceMidnight - "this.game_duration"),