DocsDataData ModelStaff

Alias: Team Member

Represent a person who work in an healthcare facility as medical or non-medical staff.

Schema

Property NameTypeRequired
team_idstringYES
user_idstringYES
typeCodedConceptYES
statusCodedConceptYES
membership_keystringNO

Auto-generated by better-auth

Property NameTypeNative Type (PostgreSQL)
idstringtext
created_atstringtimestampz

Example

{
  "id": "123",
  "team_id": "123",
  "user_id": "123",
  "type": {
    "system": "crn:staff",
    "value": "medical",
    "display": "Medical"
  },
  "status": {
    "system": "crn:status:system",
    "value": "active",
    "display": "Active"
  },
  "membership_key": null,
  "created_at": "2026-10-02 21:27:00+07"
}

Important Notes

Additional Field

Better Auth Organization plugin team member schema only consist of id, teamId, userId, membershipKey, createdAt. The other property defined above are additional field you must add in your better auth configuration like below

const auth = betterAuth({
  plugins: [
    organization({
      schema: {
        teamMember: {
          additionalFields: {
            type: {
              type: "string",
              required: true,
              input: true,
            },
            status: {
              type: "string",
              required: true,
              defaultValue: JSON.stringify({
                system: "crn:status:system",
                value: "active",
                display: "Active",
              }),
              input: true,
            },
          },
        },
      },
    }),
  ],
});

Read here to learn more on how to extend better auth core schema.

Case Style

Better Auth uses camelCase by default. To keep your database schema consistent in snake_case, add the following configuration:

const auth = betterAuth({
  plugins: [
    organization({
      schema: {
        teamMember: {
          fields: {
            teamId: "team_id",
            userId: "user_id",
            membershipKey: "membership_key",
            createdAt: "created_at",
          },
        },
      },
    }),
  ],
});
Info

Type inference in your code will still use the original field names (e.g., teamMember.createdAt, not teamMember.created_at).

Built with LogoFlowershow