I want to define a custom structure in my indexed database. How can I define a document structure in an indexed database?
Let’s say:
I have one people class
export class People {
id : number
name: string
lists: LookUp[]
constructor() { }
}
And the LookUp class is:
export class LookUp {
id: number
name: string
constructor() { }
}
As a simple structure I define it the below way:
const dbConfig: DBConfig = {
name: 'MyDb',
version: 1,
objectStoresMeta: [{
store: 'people',
storeConfig: { keyPath: 'id', autoIncrement: true },
storeSchema: [
{ name: 'name', keypath: 'name', options: { unique: false } }
]
}]
};
Now I am stuck with the list define (lists: LookUp[]
). How can I define the list?
I got the clue to solve it.
Define it this way:
And add data like this way:
It will solve my issue.