node-georedis
node-georedis copied to clipboard
Set/get metadata at locations in addition to name
Hi,
GeoRedis feature currently utilizes 3 properties: latitude, longitude, and name. When adding a location, is it possible to add additional key value pairs aside from name itself? Let us say we are adding name, address, etc. Is it possible? If not, what are best workaround / practices?
closed... duplicate found. https://github.com/arjunmehta/node-georedis/issues/6
@vvavepacket Yeah, best bet is to have another hash store based on names. Redis stores everything as strings or numbers, but you can use hmset
/hmget
at least have some metadata. ie. client.hmset("mylocationname", { a: 1, b: 2, c: 'xxx' })
Redis isn't super great for relational queries or storing complex objects at a key. Though, I actually think it could be a nice convenience to be able to store simple metadata for a location. It would be probably be limited to a shallow object of either strings and numbers.
I would like to leave this open as a feature request.
Ideally the API would look like:
geo.addLocation('locationname', position, {
address: '265 Homer Lane',
city: 'Lalaland, CA',
rank: 3
})
geo.location('locationname', function(err, location) {
console.log('Location information', location.data);
})
But, I'd really have to consider how to implement this without drastically reducing performance. Particularly for the getting of location metadata. I think the retrival of metadata may have to be an option, like:
geo.location('locationname', { withData: true }, function(err, location) {
console.log('Location information', location.data);
})
That way we could gate whether or not to make an additional request for data.
+1
maybe instead of:
geo.addLocation('locationname', position, {
address: '265 Homer Lane',
city: 'Lalaland, CA',
rank: 3
})
we can work with:
geo.addLocation('locationname', {
latitude: 43.6667,
longitude: -79.4167,
address: '265 Homer Lane',
city: 'Lalaland, CA',
rank: 3
})
latitude -> required longitude -> required