Notes

The code generated by Dreamer is 100% compatible with AdonisJS 6 development standards. While Dreamer’s primary goal is to provide abstractions for common CRUD workflows to speed up development, it’s designed to work seamlessly alongside traditional AdonisJS development patterns.

You can:

  • Use Dreamer’s abstractions for standard CRUD operations
  • Create custom actions for complex scenarios using regular AdonisJS patterns
  • Mix both approaches in the same controller
  • Extend or override Dreamer’s generated code using standard AdonisJS features

For example:

import Post from '#models/post'
import { index, show, destroy } from '@oniryk/dreamer/extensions/crud'
 
export default class PostsController {
  // Using Dreamer's abstractions for standard operations
  public index = index(Post)
  public show = show(Post)
  public destroy = destroy(Post)
 
  // Custom action for complex business logic
  public async publish({ params, response }: HttpContext) {
    const post = await Post.findOrFail(params.id)
 
    await post.merge({
      status: 'published',
      publishedAt: new Date()
    }).save()
 
    await Event.emit('post:published', post)
 
    return response.status(200).send(post)
  }
}

This flexibility allows you to leverage Dreamer’s convenience while maintaining the freedom to implement custom business logic when needed.