Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set/get metadata at locations in addition to name #20

Open
vvavepacket opened this issue Jan 8, 2017 · 4 comments
Open

Set/get metadata at locations in addition to name #20

vvavepacket opened this issue Jan 8, 2017 · 4 comments

Comments

@vvavepacket
Copy link

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?

@vvavepacket
Copy link
Author

closed... duplicate found. #6

@arjunmehta
Copy link
Owner

arjunmehta commented Jan 8, 2017

@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.

@arjunmehta arjunmehta reopened this Jan 8, 2017
@arjunmehta arjunmehta changed the title additional property aside from name Set/get metadata at locations in addition to name Jan 8, 2017
@renatoeufe
Copy link

+1

@renatoeufe
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants