Working with the database

Now that we have the ability to build the table and a representation of the state that we want to save into the table, we can turn our attention to connecting to the database and actually manipulating data in it. The first thing that we are going to do is define our class as a generic type that can work with any type that extends the RecordState class we just implemented:

export class Database<T extends RecordState> {}

The reason we need to specify the type that we accept in this class is that most of the methods in it are going to either accept instances of that type as a parameter or return instances of that type to be worked with in the calling code.

As IndexedDB has become the standard client-side database, it ...

Get Advanced TypeScript Programming Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.