HigherFlyer
HigherFlyer
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
I think I may have just solved my little issue... Rubber ducky effect🦆! I'll keep this open dor a bit longer in case anyone wants to add anything/for posterity
15 replies
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
Hmmm I suppose actually I could just send one timestamp of the most recent message the client has, as if that exists than it should also have every message older than that regardless of the group (or just store the timestamp of the last time I queried the server)
15 replies
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
Before I was just doing all this in multiple requests for each group but I was trying to pair down the number of requests to just one
15 replies
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
Since messages are always in chronological order, that amounts to giving the server the timestamp of the most recent message the client has for each group and only getting the messages after that (In case it helps understand, another minimal example):
await db.query.posts.findMany({
with: {
comments: {
where: gt(posts.timestamp, CLIENT_MOST_RECENT[??]
}
}
});
await db.query.posts.findMany({
with: {
comments: {
where: gt(posts.timestamp, CLIENT_MOST_RECENT[??]
}
}
});
15 replies
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
The original example I gave is misleading for simplicity sake, there's a bit more going on I've got chats each with their own messages:
await db.query.chats.findMany({
with: {
messages: true
}
});
await db.query.chats.findMany({
with: {
messages: true
}
});
But as you can imagine there can be A LOT of messages. So, given the client caches messaged, I only want to query for what the client doesn't already have caches (aka the delta) So essentially I want to get every group my user is in, with only messages for that group I don't already have
15 replies
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
So let me restructure it a little:
15 replies
DTDrizzle Team
Created by HigherFlyer on 1/16/2024 in #help
Does orderBy guarantee evaluation order of where?
Ok yeah probably terrible approach/architecture in the first place
15 replies