Announcement Announcement Module
Collapse
No announcement yet.
Question to findAll Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question to findAll

    Hello,

    I'm currently doing an app to reserve meals online. I have following domain classes:

    Code:
    class Meal {
    
        static hasMany = [mealitems : Mealitem]
        Date date
        String title
    }
    Code:
    class Mealitem {
    
        int id
        String text
        float price    
        String imageUrl
    }
    Code:
    class Orders {
    
        User user
        Meal meal
        Date created    
        static hasMany = [mealitems : Mealitem]
    }

    I can do orders, that works out perfectly well. But when I want to display all my orders, I need to show the meal and my ordered items.

    By:
    Code:
         def user = User.findByEmail("[email protected]")
          def orders = Orders.findAllByUser(user)
          [orders : orders]
    this shows me my ordered meals BUT all its items - I just want my ordered ones.

    How can I do that?
    Thank you very much.

    Best,
    Silavn

  • #2
    Sorry, I don't understand the question. What's the problem? Also, why does an order have both a meal and meal items when the meal also has meal items? Is that duplication of information?

    Comment

    Working...
    X