title: Redux Toolkit: How to normalize group chat messages?
body: <p>I have an array of messages returned from the server where each chat message has the following format:</p>
  <pre class="lang-js prettyprint-override"><code>export interface ChatMessage {
    _id: string | number;
    text: string;
    createdAt: Date | number;
    user: ChatUser;
    groupId: number;
  }
  
  interface ChatUser {
    _id: string | number;
    name: string;
  }
  </code></pre>
  <br/>
  I want to normalize the list of messages by groupId AND then by message Id nested inside to achieve something like this:
  <pre class="lang-js prettyprint-override"><code>const messages = {
    ids: ['group1', 'group2'],
    entities: {
     group1: {
        ids: ['msg1', 'msg2'],
        msg1: {},
        msg2: {},
      },
     group2: {
        ids: ['msg3', 'msg4'],
        msg3: {},
        msg4: {},
     },
  };
  </code></pre>
  <p>How can I achieve that with <code>createEntityAdapter</code> or with the <a href="https://github.com/paularmstrong/normalizr" rel="nofollow noreferrer">normalizr</a> library?</p>