Replies: 1 comment 2 replies
-
Hey, @mauriceoc. I assume the keys in the You can pass a function to model property to generate its value. import { factory } from '@mswjs/data'
export const db = factory({
modelName: {
things: Array,
stuff: () => {
const randomKey = generateKey()
return {
[randomKey]: {
foo: 'bar'
}
}
}
}
}) I think currently you can't nest model definitions this way, so Would this achieve your goal? If not, please let me know more about it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a model instance in the form of:
Anybody know how I would specify the
stuff
object as correctly as possible in the model definitions for thefactory
function?Right now I have:
Maybe I need to convert it into an
Array
and reconstruct after it is fetched from the db?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions