title: angular NGRX: Not able to select single value in ngrx entity based on id
body: <p>I am trying to select an object by Id from the entity state. Below is my reducer.</p>
  
  <pre><code> export interface MessageState extends EntityState&lt;Message&gt; {
    // additional entities state properties
    loaded: boolean;
    loading: boolean;
  }
  
  export const adapter: EntityAdapter&lt;Message&gt; = createEntityAdapter&lt;Message&gt;({
    selectId: (msg: Message) =&gt; msg.messageId,
  });
  
  export const initialState: MessageState = adapter.getInitialState({
    // additional entity state properties
    loaded: false,
    loading: false,
  });
  
  export function reducer(state = initialState, action: MessageActionsUnion): MessageState {
    switch (action.type) {
  
      case MessageActionTypes.UPSERT_Message: {
        return { ...state, loading: true, loaded: false };
      }
  
      case MessageActionTypes.UPSERT_Message_SUCCESS: {
        return adapter.upsertOne(action.payload.Message,
          {
            ...state, loaded: true, loading: false,
          });
  
      }
  
      default: {
        return state;
      }
    }
  }
  </code></pre>
  
  <p>Below is my index.ts file</p>
  
  <pre><code>export interface State extends fromRoot.AppState {
    queueModule: QueueState;
  }
  
  export interface QueueState {
    msgHeaders: fromMsgHeaders.MessageHeaderState
  }
  
  export const reducers: ActionReducerMap&lt;QueueState&gt; = {
    msgHeaders: fromMsgHeaders.reducer
  
  };
  
  export const getQueueState$ = createFeatureSelector&lt;QueueState&gt;('queueModule');
  </code></pre>
  
  <p>I am trying to form a selector when passed an Id will return the value from the entity.</p>
  
  <pre><code>    export const selectMessages = createSelector(
        fromFeatures.getQueueState$,
        (state: fromFeatures.QueueState) =&gt; state.msgs
      );
  
      export const {
        selectAll: selectAllMessages,
        selectEntities: selectMessagesEntities,
        selectIds: selectMessagesIds,
        selectTotal: selectMessagesTotal
      } = adapter.getSelectors(selectMessages);
  </code></pre>
  
  <p>I looked at many resources, but none are clear on how to select an object by passing the id. </p>