I want to fetch my data from multiple DB in an indexed DB
here is my database in indexedDB
const DBUser = {
name: "userDB",
version: 2,
objectStoresMeta: [
{
store: "cData",
storeConfig: { keyPath: "id", autoIncrement: true },
storeSchema: [
{ name: "userId", keypath: "userId", options: { unique: false } },
{ name: "eData", keypath: "ecgData", options: { unique: false } },
{ name: "date", keypath: "date", options: { unique: false } },
],
},
{
store: "oData",
storeConfig: { keyPath: "id", autoIncrement: true },
storeSchema: [
{ name: "userId", keypath: "userId", options: { unique: false } },
{ name: "oData", keypath: "ppgData", options: { unique: false } },
],
}
]}
I can use getAll function to fetch my data from one of the above databases. for example cData
or oData
with this code:
const { getAll } = useIndexedDB(cData);
useEffect(() => {
getAll().then(dataFromDB => {
setData(dataFromDB );
});
}, []);
When I put multiple getAll, obviously the error popped up and said Identifier 'getAll' has already been declared.
But I want to fetch my data from both cData and oData in one component. I can't have multiple getAll and without getAll, I can't fetch the data. So what is the alternative way? I don't find anything on the internet.