What is CRUD

Posted by Anantha Narayanan On 11:41 AM

A CRUD or short form for Create/Read/Update/Delete is a controller action that is built in grails for supporting basic inserting of data, querying of data, updating of data and deleting of data from table linked to a domain class.

In short, these common actions of users need not be coded for a domain class.

Consider the following example of a controller with just one line of code which enables this feature.


class BookController {
    static scaffold = true
}

The scaffold variable if its true, grails helps to auto-generate user actions for CRUD without a single line of code. The naming convention for controller follows the domain name. For a domain name Book a controller of BookController can be created.

This naming convention helps grails auto-identify your domain class and provide you with code for insert, query, update and delete for the domain class.

When the scaffold is created, grails automatically adds the above four user actions which are common for database access.

For more information on scaffolding refer Grails docs.

Recommended Post Slide Out For Blogger