TKR👑
TKR👑
DTDrizzle Team
Created by TKR👑 on 2/23/2024 in #help
Check if sql query is empty
Solved by not assigning locationSqlClause unless necessary and checking using if != undefined... linter cries a bit but works
2 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
For future readers. I solved by using sql.raw() as I think the regular sql template was causing trouble with how it passes values around (as part of injection protection). I am safe architecturally. Here is the final change I made to my toDriver definition if you need it. Above code stayed the same.
toDriver({ latitude, longitude }) {
return sql.raw(`ST_GeographyFromText('POINT(${longitude} ${latitude})')`);
}
toDriver({ latitude, longitude }) {
return sql.raw(`ST_GeographyFromText('POINT(${longitude} ${latitude})')`);
}
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
any ideas on this? @Dan Kochetov ?
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
I am using PostGIS on a PostgreSQL engine Aurora db. I simply ran the following command to support this newly needed column:
ALTER TABLE my_table
ADD coordinates GEOGRAPHY(Point);
ALTER TABLE my_table
ADD coordinates GEOGRAPHY(Point);
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
(parameter 6 is the coordinates in my schema, but I have redacted my other columns to keep my example simple above)
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
What am I missing here? I keep getting the error: PostgresError: could not determine data type of parameter $6\
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
Please help! This is such a pain in the ass and I need to launch! coordinateType.ts
import { sql } from "drizzle-orm";
import { customType } from "drizzle-orm/pg-core";

export interface Point {
latitude: number;
longitude: number;
}

export const point = customType<{
data: Point;
driverData: string;
config: {
srId: number;
};
}>({
toDriver({ latitude, longitude }) {
return sql`ST_GeogFromText('POINT(${longitude} ${latitude})')`;
},

dataType(config) {
return config?.srId
? `geography(Point, ${config?.srId})`
: "geography(Point)";
},
});
import { sql } from "drizzle-orm";
import { customType } from "drizzle-orm/pg-core";

export interface Point {
latitude: number;
longitude: number;
}

export const point = customType<{
data: Point;
driverData: string;
config: {
srId: number;
};
}>({
toDriver({ latitude, longitude }) {
return sql`ST_GeogFromText('POINT(${longitude} ${latitude})')`;
},

dataType(config) {
return config?.srId
? `geography(Point, ${config?.srId})`
: "geography(Point)";
},
});
then I use this in my schema.ts as follows:
export const myTable = pgTable("my_table", {
//bunch of other columns
coordinates: point("coordinates").notNull(),
//more columns
})
export const myTable = pgTable("my_table", {
//bunch of other columns
coordinates: point("coordinates").notNull(),
//more columns
})
and trying to make a simple request in my node application:
const newItem: dbListing = JSON.parse(event.body);
newItem.coordinates = { latitude: newItem.coordinates[1], longitude: newItem.coordinates[0] };
body = await db
.insert(myTable)
.values(newItem)
.returning();
const newItem: dbListing = JSON.parse(event.body);
newItem.coordinates = { latitude: newItem.coordinates[1], longitude: newItem.coordinates[0] };
body = await db
.insert(myTable)
.values(newItem)
.returning();
73 replies
CDCloudflare Developers
Created by Hugo on 1/25/2023 in #workers-help
Unable to use aws-sdk in production
SOLVED: this was concerning sync & async programming. Moving the part of my flow using the above API method to use synchronous logic fixed my issues when deployed. Strange there was no similar errors locally but understandable in retrospect.
4 replies
CDCloudflare Developers
Created by Hugo on 1/25/2023 in #workers-help
Unable to use aws-sdk in production
is this still the case? having a similar issue but the only command failing is AdminAddUserToGroup using the Cognito provider from the SDK. Should I pivot to using aws4fetch
4 replies
CDCloudflare Developers
Created by TKR👑 on 3/5/2023 in #functions
Pages Functions with SvelteKit
1 replies