Closed bilouw closed 3 years ago
Try this:
let comment = new Comment({ id: "123" })
comment.isPersisted = true
let post = new Post({ comment })
post.save({ with: 'comment.id' })
Just what i needed ! I did not understand that i should use isPersisted attributes to specify that the record already exist in DB.
Thanks for your help !
Also: Graphiti & Spraypaint are great tools to develop !
Thanks @bilouw !
Hi,
Let's say i want to create a Post and associate it to an already created Comment. (in my example, Comment belongs_to Post and Post has_one Comment) This is what i'm doing:
let post = new Post({ comment: new Comment})
post.comment.id = commentIdToAssociate
post.save({ with: 'comment.id' })
This code will create a new comment associated to the post with method: "create". I don't want to create this comment, i want to associate it to my post (method: "update")
I want this kind of body:
How can i do that ?
Thanks.