Radar is the location platform for mobile apps. We help companies build better products and make better decisions with location data.
Radar helps developers move faster, and we love MongoDB because it helps us move faster, too.
How? MongoDB is easy to set up with cloud database services like MongoDB Atlas, it works naturally with a JavaScript-heavy stack, and it works naturally and efficiently with geospatial data.
Much like Radar abstracts away the challenges of location context and tracking, MongoDB-as-a-service providers like MongoDB Atlas, mLab, and Compose abstract away the challenges of deploying, securing, monitoring, and scaling MongoDB clusters.
MongoDB Atlas, which is built and run by the team that contributes most of the code to the underlying database, helps companies at any stage move faster.
Radar uses JavaScript at almost every level of our stack: our dashboard is written in React, much of our backend is written in Node, and our API speaks in JSON.
MongoDB works naturally with our Java-Script heavy stack. Why?
MongoDB represents documents as BSON/JSON, and users, geofences, and events can be modeled more naturally as JSON than as rows in a relational database. For example, we represent a user document, with a user's current location and current geofences, like this:
{
_id: ObjectId("56db1f4613012711002229f5"),
location: {
type: "Point",
coordinates: [-73.988859, 40.769949]
},
geofences: [
ObjectId("56db1f4613012711002229f4")
]
}
Moreover, transforming BSON/JSON documents to JSON API responses requires minimal application logic. For example, we transform the above user document to an API response simply by removing internal fields, converting IDs to strings, and populating the user's current geofences. Much of this is done automatically by Mongoose, our ODM.
This reduces code and cognitive overhead, helping us move faster.
MongoDB provides support for GeoJSON fields like points and polygons, geospatial query operators, and geospatial indexes. Unlike PostGIS, which extends PostgreSQL, these features are built directly into MongoDB.
We can use MongoDB's geospatial features to work naturally with geospatial data.
For example, to get geofences near a user, we can use the $near
operator:
Geofence.find({
geometry: {
$near: {
$geometry: user.location,
$maxDistance: 10000
}
}
}, (err, geofences) => {
// do something with geofences
});
Or, to get geofences that a user is in, we can use the $geoIntersects
operator:
Geofence.find({
geometry: {
$geoIntersects: {
$geometry: user.location
}
}
}, (err, geofences) => {
const entered = _.difference(geofences, user.geofences);
const exited = _.difference(user.geofences, geofences);
// do something with entered and exited
});
Again, this reduces code and cognitive overhead, helping us move faster.
These features are also efficient. With minimal effort, Radar uses MongoDB's geospatial features to store millions of geofences and process hundreds of millions of locations per month.
MongoDB helps Radar move faster because it's easy to set up with MongoDB Atlas, it works naturally with a JavaScript-heavy stack, and it works naturally and efficiently with geospatial data.
If you're a developer and you want to move faster, too, try MongoDB as your database and try Radar as your location platform. We can't wait to see what you'll build.
See what Radar’s location and geofencingsolutions can do for your business.