Last active
June 11, 2018 08:23
-
-
Save Jwata/03ea406cdfe475cf8d4e876a2d1a5211 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var reactionImageUrls = {'angry': 'http://url.com/', 'wow': 'http://url.com/'}; | |
| firebase.database().ref('Points').once('value', function(points) { | |
| points.forEach(function(point) { | |
| var location = data.val().Location; | |
| var reaction = data.val().Reaction; | |
| imageUrl = reactionImageUrls[reaction]; | |
| // display a point | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| users: | |
| user_1: | |
| current_location: | |
| long: 12.345 | |
| lat: 12.345 | |
| points: | |
| - 'point_1' | |
| - 'point_2' | |
| user_2: | |
| - 'point_3' | |
| user_3: | |
| - 'point_4' | |
| points: | |
| point_1: | |
| user_id: 'user_1' | |
| reaction: 'sad' | |
| state: 'private' | |
| location: | |
| long: 12.345 | |
| lat: 12.345 | |
| time: 1528191174489 | |
| point_2: | |
| ... | |
| point_3: | |
| ... | |
| point_4: | |
| ... | |
| reactions: | |
| sad: | |
| ... | |
| joy: | |
| ... | |
| angry: | |
| ... |
Author
Author
Use case: A user finds public points around them
# Note: This isn't a real programming code.
user_id = 'some_user_id'
user = users.find_by_id(user_id)
user_location = user.current_location
distance = 10
# search logic
filtered_points = []
for point in points:
# check if it's public or not
if point.state != 'public':
continue;
# you can add any conditions as you need
# check if it's close to the user or not
if calculate_distance(point.location, user_location) < distance:
continue;
# add to filtered if it passes all conditions
filtered_points.push(point)
Author
SQL Join
| id | value | home_page |
|---|---|---|
| 1 | 'a' | 'google' |
| 2 | 'b' | 'yahoo' |
| home_page | url |
|---|---|
| 'google' | 'http://google.com/' |
| 'yahoo' | 'http://yahoo.com' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use case: A user gets their points