45
3/11/13 reveal.js - The HTML Presentation Framework ryanjarvinen.com/presentations/parks/#/ 1/45 BUILDING SPATIAL BACK-ENDS with node.js and MongoDB bit.ly/WUXJWD

Building Spatial MongoDB Apps in the Cloud

  • Upload
    mongodb

  • View
    2.065

  • Download
    0

Embed Size (px)

DESCRIPTION

This workshop will teach you how to take advantage of MongoDB's spatial indexing support as you build your own cloud-hosted app on OpenShift, Red Hat's Open Source platform as a service. OpenShift aims to provide Mongo developers with the ability to use a wide variety of programming languages, and offers MongoDB command line access, and integrated support for installing RockMongo in a single command. By the end of this session you will have all the information necessary for writing your own location based app.

Citation preview

Page 1: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 145

BUILDING SPATIALBACK-ENDS

with

nodejs

and

MongoDB

bitlyWUXJWD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 245

presented by

ryan jarvinen ryanj

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 345

Open Platform Evangelistat

Red Hat

ryanjredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 445

AGENDALearn some basic spatialLoad spatial data into MongoDBRun a query or twoGo live with a Mongo-powered spatial app in ~30 mins

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 545

CODE DU JOURhttpsgithubcomopenshiftopenshift-mongo-node-

express-example

Signup with Code - MONGOLA2013

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 645

THE CLOUDIS

A FREE-MARKET FOR ONLINE SERVICES

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 2: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 245

presented by

ryan jarvinen ryanj

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 345

Open Platform Evangelistat

Red Hat

ryanjredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 445

AGENDALearn some basic spatialLoad spatial data into MongoDBRun a query or twoGo live with a Mongo-powered spatial app in ~30 mins

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 545

CODE DU JOURhttpsgithubcomopenshiftopenshift-mongo-node-

express-example

Signup with Code - MONGOLA2013

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 645

THE CLOUDIS

A FREE-MARKET FOR ONLINE SERVICES

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 3: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 345

Open Platform Evangelistat

Red Hat

ryanjredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 445

AGENDALearn some basic spatialLoad spatial data into MongoDBRun a query or twoGo live with a Mongo-powered spatial app in ~30 mins

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 545

CODE DU JOURhttpsgithubcomopenshiftopenshift-mongo-node-

express-example

Signup with Code - MONGOLA2013

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 645

THE CLOUDIS

A FREE-MARKET FOR ONLINE SERVICES

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 4: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 445

AGENDALearn some basic spatialLoad spatial data into MongoDBRun a query or twoGo live with a Mongo-powered spatial app in ~30 mins

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 545

CODE DU JOURhttpsgithubcomopenshiftopenshift-mongo-node-

express-example

Signup with Code - MONGOLA2013

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 645

THE CLOUDIS

A FREE-MARKET FOR ONLINE SERVICES

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 5: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 545

CODE DU JOURhttpsgithubcomopenshiftopenshift-mongo-node-

express-example

Signup with Code - MONGOLA2013

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 645

THE CLOUDIS

A FREE-MARKET FOR ONLINE SERVICES

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 6: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 645

THE CLOUDIS

A FREE-MARKET FOR ONLINE SERVICES

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 7: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 745

THE CLOUD LANDSCAPE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 8: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 845

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 9: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 945

THE BIG PICTURE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 10: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1045

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 11: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1145

OPENSTACK

IS OPENand

FOCUSED ON IAAS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 12: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1245

PUBLIC CLOUD +PRIVATE CLOUD =

HYBRID CLOUD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 13: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1345

OPENSHIFT IShellip

OPEN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 14: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1445

OPEN CARTRIDGEFORMAT

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 15: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1545

OPEN SOURCE

OPENSHIFT ORIGIN

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 16: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1645

HOSTING OPTIONSDIY

OPENSHIFT ONLINEOPENSHIFT ENTERPRISE

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 17: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1745

DEVELOPER PREVIEWMake sure that you sign up for a

Free-as-in-beerFree-as-in-freedom512 MB RAM 1 GB storage per gears (3 free)Need more resources just askREALLY a Developer Preview

free OpenShift account

httpopenshiftredhatcom

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 18: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1845

GETTING STARTED WITH OPENSHIFTPRE-REQUISITES

ruby rubygemsgit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 19: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 1945

INSTALLING THE RHC CLIENT TOOLand

install

sudo gem install rhc

nodejs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 20: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2045

HELP WITH CLIENT TOOLSOpenshift Getting Started guideRHC client tools installation

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 21: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2145

CONFIGURING YOUR DEV ENVIRONMENTsets your openshift email addressverifies your ssh key configurationselects your application namespace

rhc setup

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 22: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2245

MONGODB SPATIAL

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 23: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2345

SPATIAL NOTESMongoDB currently supports the following types of

spatial queries1 Near2 Containment

MongoDB GIS summaryhttpwwwmongodborgdisplayDOCSGeospatial+Indexing

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 24: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2445

MONGODBASSUMPTIONS

Assumes coords are between -180 and 180Can handle any 2D coordinatesHas methods to handle curvature of the earth(spherical)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 25: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2545

MAKING IT WORK1 Put your data in an array

2 Add a 2d index to your collection

loc [ 50 30 ] SUGGESTED OPTION loc x 50 y 30 loc foo 50 y 30 loc lon 40739037 lat 73992964

dbplacesensureIndex( loc 2d )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 26: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2645

GEARING UP A NEW APP ON OPENSHIFTor

rhc app create APP_NAME APP_CARTRIDGE

rhc app create parks nodejs mongodb-22 --from-code=httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 27: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2745

Application Options------------------- Namespace ryanj Cartridges nodejs-06 mongodb-22 Source Code httpsgithubcomopenshiftopenshift-mongo-node-express-examplegit Gear Size default Scaling no

Creating application parks done

Waiting for your DNS name to be available done

Downloading the application Git repository Cloning into parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 28: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2845

parks httpparks-ryanjrhcloudcom (uuid 25918304bf8d406e89802a1e642063a0)--------------------------------------------------- Created 1023 PM Gear Size small Git URL ssh25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom~gitparksgit SSH 25918304bf8d406e89802a1e642063a0parks-ryanjrhcloudcom

nodejs-06 (Nodejs 06) ------------------------

RESULTApplication parks was created

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 29: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 2945

Adding mongodb-22 to application parks Success

mongodb-22 (MongoDB NoSQL Database 22)---------------------------------------- Connection URL mongodb127610212927017 Database Name parks Password T5xJwCiDZYGn Username admin

RESULTAdded mongodb-22 to application parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 30: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3045

SUCCESSYou now have a basic nodejs app up an running on

OpenShift

Your gear is now configured with

its own git repoits own web serverMongoDBssh accessloggingpublicly accessible DNS

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 31: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3145

BUILDING YOUR APP cd parks

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 32: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3245

SETTING UP MONGODB ON OPENSHIFTrhc cartridge add mongodb-22

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 33: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3345

INSTALLING DEPENDENCIESUsing Nodes

Include the -S flag in order to save this dependency toyour applications packagejson file

npm package managernpm install mongojs -S

httpnpmjsorgpackagemongojs

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 34: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3445

COMMITTING YOUR CHANGESCommit your changes locally

git add packagejson serverjs

git commit -m adding mongojs npm dependency initializing mongojs library adding a basic API

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 35: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3545

DEPLOYMENTDoneYour spatial app should now be live IN THE CLOUD

git push

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 36: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3645

ROCKMONGO ON OPENSHIFT(optional)

rhc cartridge add rockmongo-11

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 37: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3745

CONNECTING TO MONGODBvar mongojs = require(mongojs)var connection_string = bot_nameif(processenvOPENSHIFT_MONGODB_DB_PASSWORD) connection_string = processenvOPENSHIFT_MONGODB_DB_USERNAME + + processenvOPENSHIFT_MONGODB_DB_PASSWORD + + processenvOPENSHIFT_MONGODB_DB_HOST + + processenvOPENSHIFT_APP_NAMEvar db = mongojs(connection_string [scoreboard])

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 38: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3845

SSH TO THE CLOUDFIND YOUR APPS SSH ADDRESS

SSH IN TO YOUR OPENSHIFT GEARrhc app show parks

rhc ssh -a APP_NAME

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 39: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 3945

IMPORTING YOUR DATAmongoimport -d parks -c parkpoints --type json --file $OPENSHIFT_REPO_DIRparkcoordjson -h $OPENSHIFT_MONGODB_DB_HOST -u admin -p $OPENSHIFT_MONGODB_DB_PASSWORD

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 40: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4045

ADDING A 2D INDEXCONNECT TO MONGODB CLI

SELECT YOUR COLLECTION

ADD THE 2D INDEX

mongo

use parks

dbparkpointsensureIndex(pos2d)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 41: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4145

SPATIAL QUERIESFINDING POINTS NEAR hellip

FIND BY NAME (REGEX)

GEONEAR

dbparkpointsfind(pos $near [-37 41])

dbparkpointsfind( Name lincolni pos $near [-3741] )

dbrunCommand( geoNear parkpoints near [-3741] num 10 )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 42: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4245

ADDING CHECK-INSCREATE A NEW COLLECTION FROM SCRATCH

INSERT A NEW RECORD

QUICK QUERY TO MAKE SURE IT WORKED

dbcreateCollection(checkin)dbcheckinensureIndex( pos 2d )

dbcheckininsert( created new Date() Notes just landed pos [-767302 255332 ] )

dbcheckinfind( pos $near [-3741] )

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 43: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4345

ADD A SECOND DOCUMENT CLOSER TO QUERY POINTTHIS IS AN UPSERT - SINCE WE DONT PASS IN THE _ID IT CREATES A NEW RECORD

ONE WAY TO UPDATE ORIGINAL DOCUMENT

dbcheckinsave( created new Date() Notes that was a big step pos [-377302 405332 ])

myDoc = dbcheckinfindOne(_id ObjectId(50130d8ea8f6532e83026bc1))myDocNotes = really the landingdbcheckinsave(myDoc)

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 44: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4445

CONCLUSIONS1 Spatial on MongoDB is easy and fun2 You can now build your own FourSquare or other

checkin application3 You can also build your own field data entry system4 You can build and deploy your application quickly

without having to think about infrastructure

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013

Page 45: Building Spatial MongoDB Apps in the Cloud

31113 revealjs - The HTML Presentation Framework

ryanjarvinencompresentationsparks 4545

Thanks for following along--ryanj

Signup Code MONGOLA2013