gau000
gau000

Reputation: 45

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
})

Upvotes: 1

Views: 366

Answers (1)

timdeschryver
timdeschryver

Reputation: 15487

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?

Upvotes: 0

Related Questions