CRUD operations on a database in Play - scala

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

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.

Is there any caching mechanism in Slick?

I'm new in Slick and Play and I can't find any references about caching in docs(2 and 3rc). Is there any native way in Slick for cache organization or if not tell me, please, why and whats the reasons for not having it? Summary, I hope that somebody help me in this question or show another better way.
I don't think Slick has got anything, it is just for interacting with a RDBMS. But since you are using play framework you have the play cache API:s that you can use, for example in a DAO that wraps Slick. You can read more about it in the play framework docs here: https://www.playframework.com/documentation/2.3.x/ScalaCache
Also see http://slick.typesafe.com/doc/2.1.0/orm-to-slick.html#read-caching and the following section

Resquest MongoDB with scala

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

Scaffolding for Play Framework 2

Is there scaffolding generator utility for Play Framework 2 for Scala like Ruby on Rails has? I found some topics about this but didn't figure out which one was most popular or even if there was the standard one?
Your thoughts?
UPDATE: I mean scaffolding for generating controllers, views, models or any of them.
If you're using MongoDB, the reactive mongo plugin has an auto source feature, which gives you a REST scaffolding API:
http://mandubian.com/2013/06/11/play-autosource/
Slick can generate models from your database tables. They aren't play specific so I think you'd have to write controllers yourself, but it's a start.
https://scala-slick.org/

Is it feasible to build company specific framework that wraps NHibernate?

I heard that companies that use Java technologies, they used to build their own custom Framework that wraps Hibernate. However, is it really feasible for their .Net peers to do the same thing with NHibernate or Entity Framework?
This is almost always a horrible idea - I think Ayende sums it up best in this article. In general, you should consider NHibernate itself to be the "wrapper" around your data access - attempting to build an abstraction layer on top of it is probably going to be a losing proposition.
Actually, you should check out some of the articles on .NET Junkie's weblog. He wrote several great posts on how to deal with repositories, queries, commands and so on. We've been using these in a very large enterprise system where we switch between an in-memory dictionary, an in-memory SQLite database and a production environment using SQL Server or Oracle. Obviously, we use NHibernate for this.
I use the repository pattern and a separate project/dll to abstract away the data framework nhibernate / entity framework. this is a good starting point http://codebetter.com/petervanooijen/2008/04/04/wrapping-up-nhibernate-in-repositories/