rusty_postgres

Macro nearby_location

Source
macro_rules! nearby_location {
    (@format $connection:expr,$model:expr,$client:expr) => { ... };
    (connection => $connection:expr,model:$model:expr,select:{$($select:expr),*},location:{
        lattitude:$lattitude:expr,
        longitude:$longitude:expr
    },select_from:{$select_location:expr},
    order:{$order:expr}
) => { ... };
    (connection => $connection:expr,model:$model:expr,select:{$($select:expr),*},location:{
        lattitude:$lattitude:expr,
        longitude:$longitude:expr,
        within:$within:expr
    },select_from:{$select_location:expr},
    order:{$order:expr}
) => { ... };
    (connection => $connection:expr,model:$model:expr,select:{$($select:expr),*},location:{
        lattitude:$lattitude:expr,
        longitude:$longitude:expr,
        within:$within:expr
    },select_from:{$select_location:expr}
) => { ... };
    (connection => $connection:expr,model:$model:expr,select:{$($select:expr),*},location:{
        lattitude:$lattitude:expr,
        longitude:$longitude:expr
    },select_from:{$select_location:expr}
) => { ... };
}
Expand description

ยงExample

let location = nearby_location! {
connection => postgres,
model:"shop",
select:{
    "other_than_location_type"
},
location:{
    lattitude:"12.971599",
    longitude:"77.594566"
},
select_from:{
    "location"
}
};
let location = nearby_location!(
connection => conn,
model: "places",
select: {"id", "name"},
location: {
    lattitude: 37.7749,
    longitude: -122.4194
},
select_from: {"geom"},
order: {"ASC"}
);
let location = nearby_location!(
connection => conn,
model: "restaurants",
select: {"id", "name", "rating"},
location: {
    lattitude: 40.7128,
    longitude: -74.0060,
    within: 5000
},
select_from: {"location"},
order: {"ASC"}
);
let location = nearby_location!(
connection => conn,
model: "hotels",
select: {"id", "name"},
location: {
    lattitude: 48.8566,
    longitude: 2.3522,
    within: 1000
},
select_from: {"coordinates"}
);
let location = nearby_location!(
connection => conn,
model: "landmarks",
select: {"id", "name", "address"},
location: {
    lattitude: 51.5074,
    longitude: -0.1278
},
select_from: {"geo_column"}
);