Abdulramon Jemil
Explore posts from serversDTDrizzle Team
•Created by Abdulramon Jemil on 9/8/2024 in #help
How does Drizzle ORM map PostgreSQL dates with regard to timezones?
Sorry for reposting this as I initially posted it in discussions.
So how does Drizzle actually handle dates and timestamps for Postgres. It is mentioned here that drizzle provides string or "mapped dates": https://orm.drizzle.team/learn/latest-releases/drizzle-orm-v0300
What exactly does "mapped dates" mean? When using a
timestamp without timezone
in postres with drizzle, based on the statements on that page, I assume it converts the passed date object to utc format using .toISOString()
and then passes it to postgres. Since it is without timezone, Postgres does no offset adjustment. So what happens when retrieving such fields inside of drizzle when using mode: "date"
? Does drizzle pass the date string retrieved from postgres to new Date()
directly? In this case, the date (since it has no timezone information) will be assumed to be in the timezone of the call to new Date()
. On the other hand, does Drizzle parse the date string and append the UTC timezone info before passing to new Date()
so that new Date()
treats the date as UTC?
My understanding is this: if the time is 2:00AM GMT + 1
, then toISOString()
effectively gives 1:00AM GMT
and the timezone is ignored for timestamp without timezone
. This 1:00AM
is stored and retrieved from Postgres as is. Now when this gets retrived at a GMT+3
timezone, what happens? Which Date
is returned by drizzle
- 1:00AM GMT + 3
(if the time is passed to new Date()
without timezone info) or
- 4:00AM GMT + 3
(if Drizzle modifies the date string to include timezone or adds manually adds the current timezone offset of GMT + 3
).
I believe it has to be one of these two since JavaScript dates only have one data field which is the timestamp and contain no timezone information in them. new Date()
will take the passed time as though it is for the local timezone (rather than UTC) if the passed time string itself doesn't include a timezone info.
Thanks in advance10 replies
CCConvex Community
•Created by Abdulramon Jemil on 9/7/2024 in #support-community
Unable to log in
GitHub suspended my account about 10 days ago for reasons I don't know, and I've reached out to them getting no correspondence whatsoever. Because of it, I'm not unable to log in to my Convex dashboard. Convex doesn't support any other login methods. What should I do?
1 replies
CCConvex Community
•Created by Abdulramon Jemil on 8/23/2024 in #support-community
What's the name of the cookie used by Convex Auth?
I would like to know what name convex auth uses to keep track of session tokens. I like knowing how tools I use work so I can make modifications at any time. By logging into
https://labs.convex.dev/auth-example
, I noticed that login state works even when there are no cookies, and later found out that Convex auth uses localStorage by default unless when using @convex-dev/auth/nextjs
. Anyways, I have something like the ff in localStorage:
1- Is there a documentation for the exact names used for the tokens similar to what Clerk has here: https://clerk.com/docs/deployments/clerk-cookies#strictly-necessary-application-cookies. It is always good to know about the magic done by the library, since I might want to read them and pass them around myself somewhere especially on the server. I know there are certain utilities for Next.js, but I still want to know. (Also, even though the chances of collision with my own set cookie/localstorage values is extremely low, it's not zero.) From the sample above, it's evident that the string is built from the cloud URL with some prefix.
2- Is there a documentation for how to verify such tokens manually similar to what clerk has here https://clerk.com/docs/backend-requests/handling/manual-jwt.
3- Are these names the same for localstorage and cookies (guess this can be answered by 1 above).4 replies
CCConvex Community
•Created by Abdulramon Jemil on 8/22/2024 in #support-community
Why not `ctx.db.query("table").withIndex(vectorIndex)`?
This is just out of curiosity, why not
ctx.db.query("table").withIndex(vectorIndex)
but instead ctx.vectorSearch()
? Is it because we don't want to expose ctx.db
in actions?
In fact, why is there no ctx.db.query()
in actions? Is there a reason for not allowing querying dB in actions? Seems to me like it should be fine since unlike mutations, determinism (or non-determinism) of the calling function (an action in this case) doesn't affect anything.
Concerning the first question, we can just use Typescript to narrow down the indexes in the withIndex()
of queries and mutations to non-vector indexes, while allowing all indexes in actions.7 replies
CCConvex Community
•Created by Abdulramon Jemil on 8/22/2024 in #support-community
Bad example in docs
In the vector search docs (https://docs.convex.dev/search/vector-search#using-a-separate-table-to-store-vectors), there is the following example:
This example uses
await
inside of a for
loop, which I believe is from convex-demos/vector-search
(https://github.com/get-convex/convex-demos/blob/d7e772bf8dcf694a075556c639a0c645b833e4a4/vector-search/convex/movies.ts#L110), and this is, in general a bad practice, and it becomes evident when there's a large number of id
s to enumerate, resulting in very long response times. A better solution would be to use Promise.all
and Array.prototype.filter
as follows:
2 replies
CCConvex Community
•Created by Abdulramon Jemil on 8/22/2024 in #support-community
How OIDC with Convex Auth works with HTTP actions endpoints
So when using convex auth, the authorization URL is the convex site URL available via
CONVEX_SITE_URL
system environment variable. From what I understand, specific endpoints defined by the OpenID spec are expected on such domain/URL (to conform to the spec). Examples of such endpoints are the /token
and the /authorize
. However, this same CONVEX_SITE_URL
is used for HTTP actions, such that if I have an HTTP action at convex/token.ts
, then the action is accessible by ${CONVEX_SITE_URL}/token
(assuming I have it configured to work that way).
Does this not conflict with the /token to be used for auth by convex auth as required by the OpenID spec?13 replies