Files
payload/packages/db-postgres/src/transform/read/hasManyText.ts
Gokulsck f43cf185d4 feat: hasMany property for text fields (#4605)
* fix for supporting hasMany property in text field

* Updated docs

* handle text case types for schema and graphql schema

* fix unit test for required failing

* add unit test for has many text field

* add end to end test for has many on text field creation

* support has many feature for text field on postgres

---------

Co-authored-by: Chris Heinz <chrisi.heinz@web.de>
2024-01-04 14:45:00 -05:00

20 lines
442 B
TypeScript

/* eslint-disable no-param-reassign */
import type { TextField } from 'payload/types'
type Args = {
field: TextField
locale?: string
textRows: Record<string, unknown>[]
ref: Record<string, unknown>
}
export const transformHasManyText = ({ field, locale, textRows, ref }: Args) => {
const result = textRows.map(({ text }) => text)
if (locale) {
ref[field.name][locale] = result
} else {
ref[field.name] = result
}
}