in this simple todo app example i have the media field in my todo collection defined as
{ name: 'media',
type: 'upload',
relationTo: 'media',
}```
then I am trying to use the local api on a formAction to create a new todo :
```typescript
import { Media } from '@/payload-types'
import payloadConfig from '@/payload.config'
import { getPayload } from 'payload'
import sharp from 'sharp'
export async function createTodoAction(formData: FormData) {
'use server'
const title = formData.get('title') as string
const description = formData.get('description') as string
const completed = formData.get('completed') ? true : false
const media = formData.get('media') as File
const payload = await getPayload({ config: payloadConfig })
await payload.create({
collection: 'todos',
data: {
title,
description,
completed: completed,
media: {
// What do I do here ???
}
},
})
}
This is built on top of the blank template.
I am stuck here because i don't understand what/how to reference my media object. Should I first do a create in my media collection for the image only and then attempt a create to my toto collection by refering the (already existing by now) media instance ?
If so, How do i reference it ? Im a bit confused