terryball
terryball
Explore posts from servers
PD🧩 Plasmo Developers
Created by terryball on 8/22/2024 in #👟framework
Environment vars with manifest override arrays
I have an array of urls in the host permission section of my manifest override in my package.json:
"host_permissions": [
"http://localhost/*",
"https://*.mydomain.com/*",
"$PLASMO_PUBLIC_STAGING_ONLY_URL/*"
],
"host_permissions": [
"http://localhost/*",
"https://*.mydomain.com/*",
"$PLASMO_PUBLIC_STAGING_ONLY_URL/*"
],
I would like to remove http://localhost/* and $PLASMO_PUBLIC_STAGING_ONLY_URL/* when I build for production. I don't have the PLASMO_PUBLIC_STAGING_ONLY_URL variable set in my .env.production. When I build my extension, the variable name is hardcoded into my host_permissions array in the resulting manifest.json. Any tips on how to configure this properly would be much appreciated.
4 replies
DTDrizzle Team
Created by terryball on 6/3/2024 in #help
Ok to delete old migration files?
Would it be ok if I deleted all of my historical, applied migration files assuming they are stored in my git history? What about meta snapshot.json files? Thanks for the help!
5 replies
DTDrizzle Team
Created by terryball on 3/14/2024 in #help
Type error working with Postgres dates in v.0.30.1
I'm using Drizzle with postgresjs and recently updated to v0.30.1, where I know the driver was updated to always return strings for dates. After the update, many of my queries then failed with an error ERR_INVALID_ARG_TYPE: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date". Here's an example of a failed query that produced that error message:
const startDate = subDays(new Date(), 30) // Date object

const results = await db
.select({
id: sessions.id,
userId: sessions.userId,
})
.from(sessions)
.where(gte(sessions.timestamp, startDate))
const startDate = subDays(new Date(), 30) // Date object

const results = await db
.select({
id: sessions.id,
userId: sessions.userId,
})
.from(sessions)
.where(gte(sessions.timestamp, startDate))
Where sessions.timestamp is defined as timestamp('timestamp', { mode: 'date', withTimezone: true }) in my schema. When I convert startDate to a string with .toISOString(), the query works, but I get the following type error:
No overload matches this call.
Overload 1 of 3, '(left: PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>, right: Date | SQLWrapper): SQL<...>', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'Date | SQLWrapper'.
Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.
No overload matches this call.
Overload 1 of 3, '(left: PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>, right: Date | SQLWrapper): SQL<...>', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'Date | SQLWrapper'.
Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.
Any tips would be appreciated. Thank you!
9 replies
DTDrizzle Team
Created by terryball on 1/25/2024 in #help
SELECT DISTINCT error in Drizzle query but not in raw query
Hi everyone, I'm getting a Postgres Error: SELECT DISTINCT, ORDER BY expressions must appear in select list, when Drizzle is executing a particular query. However, when I copy and paste the raw query generated by Drizzle and substitute in the params, I don't get any error and the query executes successfully. Here's the raw query that works: SELECT DISTINCT "sessions"."id", "sessions"."timestamp", "vendors"."id", "vendors"."name", "vendors"."logo_url", similarity ("vendors"."name", 'charge') FROM "app"."sessions" INNER JOIN "vendors"."vendors" ON "sessions"."vendor_id" = "vendors"."id" WHERE similarity ("vendors"."name", 'charge') >= 0.2 ORDER BY (similarity ("vendors"."name", 'charge')) DESC And here is the Drizzle code that is generating this query and the error: const results = await db .selectDistinct({ id: sessions.id, timestamp: sessions.timestamp, vendor: { id: vendors.id, name: vendors.name, logoUrl: vendors.logoUrl, }, relevance: searchFn, }) .from(sessions) .innerJoin(vendors, eq(sessions.vendorId, vendors.id)) .where(gte(searchFn, 0.2)) .orderBy(desc(searchFn)) Would appreciate any tips. Thanks!
5 replies
DTDrizzle Team
Created by terryball on 1/16/2024 in #help
Safe to delete migration files?
Apologies if this is kind of a beginner question, but I'd like to know if it's safe to delete my migration SQL files purely for cleanup/organization purposes? What about the snapshot.json files? Thank you!
6 replies
DTDrizzle Team
Created by terryball on 11/15/2023 in #help
Chaining/combining $dynamic query functions
Hi everyone - I'm trying to take advantage of the new dynamic query building feature to simplify the way I query my db for displaying data in a table. I've already implemented a nice helper function to add ORDER BY to a query, e.g: const result = await withOrderBy(qb, { orderBy: 'name', order: 'desc' }) And now I'd like to do the same for pagination, just like in Drizzle's docs: const result = await withPagination(qb, { page: 2, pageSize: 10 }) What's the cleanest way to use both of these helpers? Nesting them does technically work: const result = await withPagination( withOrderBy(qb, { ...args }), {page: 2, pageSize: 10} ) But that seems pretty hard to read and work with. Has anyone figured out a better way? Thank you!
10 replies