Skip to content

use column value as comparison in query #2913

Closed
@florianbepunkt

Description

@florianbepunkt

Is it possible to use column values for comparison in queries?

Background: I have some kind of dating app, using parse-server as backend. Each user has two fields: a radius field and a geopoint field. In radius field users store in which radius they are looking for other users. I want to to do a two way geo query now…show users other users based on their location and radius setting.

Example: User A and User B are 5 miles apart. User A has a radius he wants to search of 10 miles, user B only has a radius of 1 mile. If user a does a query he should get no results, since user b is within his radius, but he himself (user a) is not within user b's radius.

A one-way check, to see if user B is within user a's radius is simple:
query.withinKilometers('lastLocation', user.get('lastLocation'), user.get('lookingForRadius'));

But I struggle to to the second check to see whether user a is also within user B's radius. For this I would nee to use a column value for comparison in my query.

Pseudo-code would be this
query.withinKilometers('lastLocation', user.get('lastLocation'), 'userRadiusColumnValue');

where userRadiusColumnValue would not be a fixed value but a column value that would change for each row that is queried.

Is this possible in Parse-server? If not, is there another approach to these scenarios where you would need to compare column values in a query?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions