I have three data models for amplify datastore - User, Dashboard, UserDashboard. Where UserDashboard contains id of both User and Dashboard model.
"UserDashboard": {
"name": "UserDashboard",
"fields": {
"id": {
"name": "id",
"isArray": false,
"type": "ID",
"isRequired": true,
"attributes": []
},
"user": {
"name": "user",
"isArray": false,
"type": {
"model": "User"
},
"isRequired": true,
"attributes": [],
"association": {
"connectionType": "BELONGS_TO",
"targetName": "id"
}
},
"dashboard": {
"name": "dashboard",
"isArray": false,
"type": {
"model": "Dashboard"
},
"isRequired": true,
"attributes": [],
"association": {
"connectionType": "BELONGS_TO",
"targetName": "id"
}
}
}
When I am trying to save data in UserDashboard, I am getting error: "Failed to execute 'get' on 'IDBIndex': No key or key range specified".
to save data I am using this code:
let dashboard = await DataStore.save(
new Dashboard({
DashboardId: "testDashboard",
createdAt: new Date().toISOString()
})
)
let user = await DataStore.save(
new User({
UserId: "testUserId",
createdAt: new Date().toISOString()
})
)
let userDashboard = await DataStore.save(
new UserDashboard({
user: user.id,
dashboard: dashboard.id
})
)
How to solve the issue?