I’m looking to store location details to show on a...
# prisma-whats-new
n
I’m looking to store location details to show on a map for an
Event
type, I’m thinking of using a node
geocoder
lib to get the long/lat, would you suggest storing this within a Json type? or two fields? I’ll also store the location as a string that the user types (which is used to lookup long/lat)
n
I’ll also store the location as a string that the user types (which is used to lookup long/lat)
what do you mean with that @notrab?
n
The Event form will ask for event name, description and location.
location
is what I’ll use within the
geocoder
to lookup the
long/lat
.
n
do you even need to store long/lat at all when you can rely on
geocoder
?
n
Yeah, seems silly to lookup that info when it doesn’t change (unless location is changed - fires another call)
n
typically I recommend having a separate
Location
model with `lng`/`lat` fields of type float
in your case you could have an additional string field for the location name used for the lookup
then have a one-to-one relation between
Event
and
Location
n
Yeah, maybe, maybe too much abstraction as I highly doubt an event will occur at the same location (on an app as small as I’m doing).
Thanks for reminding me about Float.
n
if you plan to use Algolia geo queries, it's required to have a separate
Location
model with these fields. If you don't plan to use that, then you can basically model it however makes most sense to you 🙂
n
Thanks for the heads up