Code Monkey home page Code Monkey logo

play-reactive-mongo-db's Introduction

Example application using play 2.5 and reactive mongo

Configure MongoDB

Just change it in application.conf

mongodb.uri = "mongodb://localhost/persons"

Run it

sbt run

Cities

Cities controller uses a model, showing how simple it is in Play to parse json data from the clients

Add some cities

curl -H "Content-Type: application/json" -X POST -d '{"name":"london","population": 8539000}' http://localhost:9000/cities/
curl -X "POST" http://localhost:9000/cities/add\?name\=Paris&population\=2244000

Add some cities in bulk

curl -H "Content-Type: application/json" -X POST -d '[{"name":"tokyo","population": 13350000}, {"name":"osaka","population": 2665000}]' http://localhost:9000/cities/bulk

Search cities

curl http://localhost:9000/cities?name=Paris

See some errors

curl -H "Content-Type: application/json" -X POST -d '{"name":"london"}' http://localhost:9000/cities/

curl -H "Content-Type: application/json" -X POST -d '{"name":"london", "population": "x"}' http://localhost:9000/cities/

curl -H "Content-Type: application/json" -X POST -d '[{"name":"unknown"}]' http://localhost:9000/cities/bulk

Persons

Person controller does not use a model, following the Coast to coast Json approach

Add some persons

curl -H "Content-Type: application/json" -X POST -d '{"name":"jason","age": 12}' http://localhost:9000/persons/
curl -X "POST" http://localhost:9000/persons/add\?name\=Jason%20Voorhees\&age\=31

Add some persons in bulk

curl -H "Content-Type: application/json" -X POST -d '[{"name":"jacob","age": 35}, {"name":"rohit","age": 27}, {"name":"federico","age": 31}, {"name":"oliver","age": 33}]' http://localhost:9000/persons/bulk

Test invalid formats

curl -H "Content-Type: application/json" -X POST -d '[{"name": "pepe"}]' http://localhost:9000/persons/bulk

Search persons

curl http://localhost:9000/persons?name=jason

play-reactive-mongo-db's People

Contributors

jonasanso 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.