angularngrxngrx-storengrx-entity

ngrx adapter: composite primary key?


I have an entity with a composite primary key. Is there a way to use composite primary key ?

Here is what I try to achieve:

// My entity DailyEvent would be uniquely identified with [year, month, dayofmonth]
export interface DailyEvent {
    year: string,
    month: string,
    dayofmonth: string,
    
    eventDesc: string
}

...

export const adapter: EntityAdapter<DailyEvent> =
createEntityAdapter<DailyEvent>({
    selectId: (evt) => [evt.year, evt.month, evt.dayofmonth] // error, IdSelector must return a string|number
})

Solution

  • As far as I know this isn't possible. The event should have a unique ID, maybe that you could create create an id year.month.day?