Resquest MongoDB with scala - mongodb

I want to do an application in Scala, with a MongoDB database. I found some tutorials to use it with ReactiveMongo, I wrote my classes, but I want to test it and I don't understand how to do a simple request; to add a user for example, or find him.
What is the right method to use?

You could use the Activate framework. It supports ReactiveMongo with a simple usage interface for queries and modifications.
Using it, is also easy to switch to other types of databases, like postgre and mysql.
http://activate-framework.org/
It uses transparent persistence with efficient memory usage, providing a simpler persistence paradigm with high scalability. Take a look at http://databen.ch

Do you want ReactiveMongo or just want to use mongodb on scala. If it's the lastest, try http://mongodb.github.io/casbah/tutorial.html
Is what we use in our projects...

Related

PostgreSQL and Scala - Non-Blocking API

I would like to know if here is any library that I could use to do asynchronous database calls? I'm using PostgreSQL as my database. I came to know about slick. Is that non-blocking? Any suggestions?
From Slick documentation What is Slick?
Execution of database actions is done asynchronously, making Slick a perfect fit for your reactive applications based on Play and Akka.
In addition to Slick as mentioned by #Jean there is also ScalikeJDBC-async build on top of postgresql-async.

Difference between ReactiveMongo , Mongo-Module and MongoHelper

Mongo with Play-Framework is new for me. I have Spring-Framework background, In which we create Controller, Business and DAO layer structure applications. Now, i want to taste the flavor of Play-Framework with ReactiveMongo. For create our sample Application, my first target is to follow Controller, Business and DAO layer structure. Play-Framework already provide the basic structure of application, which is really good. If we use Mongodb with Play-Framework, I found three types of MongoDB Drivers. These are as below:
Mongo Module (https://www.playframework.com/modules/mongo-1.1/home)
MongoHelper (https://gist.github.com/harmeetsingh0013/fdc9c20b056a62f303f5)
ReactiveMongo(http://reactivemongo.org/)
ReactiveMongo, which is really awesome for implementing non-blocking I/O. In reactive mongo there are some problem with sync the data from multiple queries. I have some queries for creating sample application as below:
My first target is to implement MVC using ReactiveMongo, which i think ReactiveMongo-Extension provide me Dao layer. But i still want to confirm, ReactiveMongo-Extension is a good approach ? or I need to go for MongoHelper? What is the benefit of Mongo-Module over reactive mongo?
For dependency Injection we need to go for Spring-Dependency Injection or Guice or other Scala Dependency Injection Framework ?
If i am go for ReactiveMongo, we need to go for JSONCollection because BSONCollection is MongoDB Dependency. What is the support for JSONCollection available?
Current modules repository on playframework.com is just for Play 1.x. So Mongo Module is not an option for you.
I am the author of ReactiveMongo-Extensions and it is highly inspired from MongoHelper. You can use which one you want. If you choose ReactiveMongo-Extensions JsonDao is your friend. There is also an example application which you can check out: https://github.com/mertkavi/play-reactivemongo-extensions-sample
BTW I am currently developing a newer driver from scratch. You may also give it a try: https://github.com/fehmicansaglam/tepkin

Play framework 2 scala with MongoDB

I am new in play framework 2.
I have play 2 with scala and MongoDb requirement.
I searched lots on Play 2 and MongoDb connection, but didn't find any useful documentation.
There is lots of plugins available eg. Casbah, Reactive Mongo, Salat. So which is best for use, and which have better future?
If i want to implement my own connection to Mongo without using third party plugin, is it possible?
Please give examples and document on Play 2 and MongoDB connection.
I suggest using ReactiveMongo as its non-blocking approach is similar to how Play itself works. The API works with scala Futures which is a a really nice fit with Play's Async actions. You can also use their macros to convert case classes straight to BSON sparing quite some boilerplate code.
A lot of time has passed but I would like to share an update for those, who may search for Scala MongoDB client library for Play Framework.
Reactive Mongo is great but still lacks Play Framework 2.4 integration and MongoDB 3.0. We have waited for a long time thus wrote a library that wraps original MongodDB client in the Scala style way and is similar to Reactive Mongo in the api. Take a look at https://github.com/evojam/play-mongodb-driver. With the Play Framework module it's pretty straightforward to start, like few minutes to get working code.
This way MongoDB is nice and easy to use in Scala. We have provided a comparison of the sample query execution is in our blog post about the driver on site.

CRUD operations on a database in Play

I'd like to be able to create/delete/change a database and tables, create/delete indexes and all these kinds of things by Scala code, not by an sql file. Probably, using anorm. Is wonder, is it possible?
I know it's possible to do CRUD operations with tables.
Slick is a Scala ORM that can do most of what you're asking for, however it does not have a pure Scala way of creating a new database. You can read more about that here.
You say you are using play then start off using Ebean ORM
Have a look at
Play Persistance
and
Avaje EBean
If you have downloaded play look in the samples directory there is a computer database example. It is a very good example of CRUD
Good luck
I would recommend slick! Slick at first seems different if you are moving from directly stating your statements, but it is super handy to work with. Check it out here

Document-oriented data abstraction layer for NoSQL (Mongo)?

I'm building a server application that interfaces the world via a RESTful web service and uses MongoDB of storage. As it happens, the JSON resources of the web service are fairly close to the structure of the BSON documents stored in Mongo.
While I typically use an object-oriented DAO abstraction to hide the details of persistence implementation, it doesn't quite seem to be the best fit in this case since what I really want to do is fetch a document from the DB based on a query and perform a transformation. Building an object graph as an intermediary seems excessive.
Does anyone have any recommendations for an abstraction pattern that fits this bill?
Edit: Removed 1AM degression about just not using any abstraction and just using the Mongo driver directly.
The level of abstraction is up to you, your needs and your requirements. There are various language specific layers on top of the native MongoDB drivers. It is up to you decide what you need and not to us. We can not give recommendation without more precise and detailed background. If you ask a generic question then you will receive a generic question.
And who gave this +1? For what?