GithubHelp home page GithubHelp logo

cf-mongodb-example-app's Introduction

Example MongoDB Application Build Status

This simple application illustrates the use of the Pivotal MongoDB data service in a Ruby application running on Pivotal Cloud Foundry.

Installation

Create a MongoDB service instance

Find your MongoDB service via cf marketplace.

$ cf marketplace
Getting services from marketplace in org testing / space testing as me...
OK

service       plans     description
p-mongodb   default   MongoDB service

Our service is called p-mongodb. To create an instance of this service, use:

$ cf create-service p-mongodb default mongodb

Push the Example Application

The example application comes with a Cloud Foundry manifest.yml file, which provides all of the defaults necessary for an easy cf push.

$ cf push
Using manifest file cf-mongodb-example-app/manifest.yml

Creating app mongodb-example-app in org testing / space testing as me...
OK

Using route mongodb-example-app.example.com
Binding mongodb-example-app.example.com to mongodb-example-app...
OK

Uploading mongodb-example-app...
Uploading from: cf-mongodb-example-app
...
Showing health and status for app mongodb-example-app in org testing / space testing as me...
OK

requested state: started
instances: 0/1
usage: 256M x 1 instances
urls: mongodb-example-app.10.244.0.34.xip.io

     state     since                    cpu    memory          disk
#0   running   2014-04-10 01:42:43 PM   0.0%   75.5M of 256M   0 of 1G

If you now curl the application, you'll see that the application has detected that it's not bound to a mongodb instance.

$ curl http://mongodb-example-app.example.com/

  You must bind a MongoDB service instance to this application.

  You can run the following commands to create an instance and bind to it:

$ cf create-service mongodb default mongodb-instance
$ cf bind-service app-name mongodb-instance

Bind the Instance

Now, simply bind the mongodb instance to our application.

$ cf bind-service mongodb-example-app mongodb
Binding service mongodb to app mongodb-example-app in org testing / space testing as me...
OK
TIP: Use 'cf push' to ensure your env variable changes take effect
$ cf push

Usage

You can now read and write records by GETting and POSTing to /table/key. Be sure to create the table, first. In the example below, we create a table named entries, add a key/value pair named foo with a value of bar, and retrieve the value back from foo.

$ export APP=mongodb-example-app.example.com
$ curl -X POST $APP/entries/foo/bar
$ curl -X GET  $APP/entries/foo
bar

Of course, be sure to replace example.com with the actual domain of your Pivotal Cloud Foundry installation.

cf-mongodb-example-app's People

Contributors

cghsystems avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.