plugin schema of field type "string[]" not working properly #1072

Closed
opened 2026-03-13 08:21:24 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Maqed on GitHub (Apr 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Make a plugin with a schema of a field that has "string[]" type

export const myPlugin(){
return {
    schema: member: {
        fields: {
          projects: {
            type: "string[]",
            required: false,
          },
        },
      },
 }
}

The problem is when I try to get the data from the adapter it is a string not and array of strings.

const member = await adapter.findOne<Member>({
          model: "member",
          where: [
            {
              field: "userId",
              value: data.userId,
            },
            {
              field: "organizationId",
              value: data.organizationId,
            },
          ],
        }),
const projectArr = member.projects // returns a string instead of an array of strings

Current vs. Expected behavior

adapter returns string in string[] field in plugins. It should return a string[]

What version of Better Auth are you using?

1.2.*

Provide environment information

- OS: [Windows 11]
- Browser: [Chrome]

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)


Additional context

No response

Originally created by @Maqed on GitHub (Apr 17, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Make a plugin with a schema of a field that has "string[]" type ```ts export const myPlugin(){ return { schema: member: { fields: { projects: { type: "string[]", required: false, }, }, }, } } ``` The problem is when I try to get the data from the adapter it is a string not and array of strings. ```ts const member = await adapter.findOne<Member>({ model: "member", where: [ { field: "userId", value: data.userId, }, { field: "organizationId", value: data.organizationId, }, ], }), const projectArr = member.projects // returns a string instead of an array of strings ``` ### Current vs. Expected behavior adapter returns string in string[] field in plugins. It should return a string[] ### What version of Better Auth are you using? 1.2.* ### Provide environment information ```bash - OS: [Windows 11] - Browser: [Chrome] ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1072