MySQL Spatial Data Schema

Does anyone know how to set up a point type in a MySQL schema? I want to take advantage of spatial indexes and spatial helper functions. Currently, I am using latitude and longitude coordinates and doing some funky sin and cosine math to get all entities in a radius
1 Reply
james162861
james162861OP3mo ago
Answered it: const POINT = customType<{ data: string; notNull: false }>({ dataType() { return "point"; }, toDriver(value: string): string { return POINT(${value}); }, fromDriver(value: unknown) { return (value as string).replace(/[^0-9.,]/g, ""); }, });
Want results from more Discord servers?
Add your server