Closed shoopapa closed 1 year ago
Same issue
I was able to reproduce the issue. I'll look into a fix.
Hi @shoopapa! This is actually a duplicate of https://github.com/aws-amplify/amplify-js/issues/10864 - a known DataStore bug.
A temporary workaround would be to remove the sort key from the child model, as follows:
type Session @model @auth(
rules: [
{allow: owner}
]
) {
id: ID!
name: String
sections: [SessionSection!] @hasMany(indexName: "bySession", fields: ["id"])
}
type SessionSection @model
@auth(
rules: [
{allow: owner}
]
) {
id: ID!
sessionID: ID! @index(name: "bySession")
start: Float!
end: Float!
}
Let me know if that is an acceptable workaround for you!
Closing as duplicate. Please move discussion to https://github.com/aws-amplify/amplify-js/issues/10864.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API, DataStore
Amplify Categories
auth, api
Environment information
Describe the bug
This error is thrown when running
Datastore.delete(session)
on a model with @hasmany relationship, if I remove the relation ship then the delete function works correctly, so it seems to be a proper bug.I tried
await DataStore.delete(session)
await DataStore.delete(Session, s=> s.id.eq(id))
Expected behavior
I expect to be able to delete this model, but I currently cannot delete this model from the datastore API
Reproduction steps
using this schema and datastore save a model with relationships like so
then try to delete the session
await DataStore.delete(session)
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
iphone 13
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
react-native 0.70.6