db.$drizzle
.select({
post_id: Post.id,
content: Post.content,
post_date: Post.postDate,
profile_id: Post.profileId,
post_created_at: Post.createdAt,
post_updated_at: Post.updatedAt,
profile_name: Profile.name,
username: Profile.username,
latitude: Profile.latitude,
longitude: Profile.longitude,
profile_created_at: Profile.createdAt,
bio: Profile.bio,
type: Profile.type,
address_1: Profile.address1,
address_2: Profile.address2,
city: Profile.city,
state: Profile.state,
postal_code: Profile.postalCode,
user_id: Profile.userId,
profile_photo: Profile.profilePhoto,
})
.from(Post)
.innerJoin(Profile, eq(Post.profileId, Profile.id))
.where(
sql`ST_DistanceSphere(profiles.location, ST_MakePoint(${longitude}, ${latitude})) <= ${nearRadius}`
)
.orderBy(desc(Post.postDate))
db.$drizzle
.select({
post_id: Post.id,
content: Post.content,
post_date: Post.postDate,
profile_id: Post.profileId,
post_created_at: Post.createdAt,
post_updated_at: Post.updatedAt,
profile_name: Profile.name,
username: Profile.username,
latitude: Profile.latitude,
longitude: Profile.longitude,
profile_created_at: Profile.createdAt,
bio: Profile.bio,
type: Profile.type,
address_1: Profile.address1,
address_2: Profile.address2,
city: Profile.city,
state: Profile.state,
postal_code: Profile.postalCode,
user_id: Profile.userId,
profile_photo: Profile.profilePhoto,
})
.from(Post)
.innerJoin(Profile, eq(Post.profileId, Profile.id))
.where(
sql`ST_DistanceSphere(profiles.location, ST_MakePoint(${longitude}, ${latitude})) <= ${nearRadius}`
)
.orderBy(desc(Post.postDate))