Replies: 1 comment
-
Hey, @tarjei. Thanks for asking this. Your model definition seems correct. Here's a recap below: import { factory, primaryKey, manyOf } from '@mswjs/data'
const db = factory({
module: {
id: primaryKey(String),
lessons: manyOf('lesson')
},
lesson: {
id: primaryKey(String)
}
})
db.module.create({
lessons: [
db.lesson.create({ id: '1' }),
db.lesson.create({ id: '2' }),
db.lesson.create({ id: '3' }),
]
})
db.module.update({
where: { id: { equals: '1' } },
data: { lessons: undefined }
})
// Error: Failed to update a "MANY_OF" relationship to "lesson
// at "module.lessons" (id: "1"): cannot update a non-nullable relationship to null. You can also have nullable relationships by wrapping any relationship in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I got an entity with
How should I write this so that lessons are always an array i.e never undefined?
Beta Was this translation helpful? Give feedback.
All reactions