Skip to content
Discussion options

You must be logged in to vote

Hey @MinskLeo

Right, this is definitely a common use case but the answer is much simpler than that. If you have the id's of the tag documents you want to create a relationship to, then it would be:

const newPost = await req.payload.create({
   collection: 'posts',
   data: {
      //... other fields
      tags: [tagOne.id, tagTwo.id, tagThree.id],
   }
})

You simply pass the ID's of the tags.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MinskLeo
Comment options

@akhrarovsaid
Comment options

Answer selected by MinskLeo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants