Why use connect?
data:{
'userId': 1
}
the above one is not enough??
Why use
user:{
connect:{
id: 1
}
}
Isn't the result the same? I wonder
To answer your question, why connect
exists at all:
connect
(and disconnect
) provide an alternative interface to relations that you can also achieve by updating the respective fields directly. However, there are many cases, when the API is much more convenient.
E.g.
connectOrCreate