[PR #4000] feat(organization): make stringifying metadata optional #30729

Open
opened 2026-04-17 21:45:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4000
Author: @Drewsapple
Created: 8/14/2025
Status: 🔄 Open

Base: nextHead: feat/organization-stringify-metadata-option


📝 Commits (1)

  • d7e9cf4 feat(organization): make option for stringifying metadata before saving to db

📊 Changes

2 files changed (+23 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/adapter.ts (+17 -6)
📝 packages/better-auth/src/plugins/organization/types.ts (+6 -0)

📄 Description

I was confused by the documentation's use of the organization metadata field as an object, and set it up in my database as a jsonb column. While I understand @Kinfe123 reason of "flexibility" in #2772, allowing an object to be saved to the db enables flexibility to do much more with raw sql, including adding indices on metadata fields.

Is there a strong reason why stringifying before saving to the DB should be required? This PR provides the option to directly write the incoming Record<string, any> to the db, so that the flexibility extends to direct db queries as well, instead of forcing the flexibility to exist only within application code.

I'd be happy to update the docs as well to describe the behavior here, but I'm unsure if that should be a commit in this PR or a separate one with a docs header. LMK.


Summary by cubic

Added an option to control whether organization metadata is stringified before saving to the database, allowing direct storage of objects for more flexible querying.

  • New Features
  • Added the stringifyOrganizationMetadata option to OrganizationOptions.
  • Metadata can now be stored as either JSON strings or raw objects based on this setting.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4000 **Author:** [@Drewsapple](https://github.com/Drewsapple) **Created:** 8/14/2025 **Status:** 🔄 Open **Base:** `next` ← **Head:** `feat/organization-stringify-metadata-option` --- ### 📝 Commits (1) - [`d7e9cf4`](https://github.com/better-auth/better-auth/commit/d7e9cf44e081b9e49625774af5298260cbf6f008) feat(organization): make option for stringifying metadata before saving to db ### 📊 Changes **2 files changed** (+23 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+17 -6) 📝 `packages/better-auth/src/plugins/organization/types.ts` (+6 -0) </details> ### 📄 Description I was confused by the documentation's use of the organization metadata field as an object, and set it up in my database as a jsonb column. While I understand @Kinfe123 reason of "flexibility" in #2772, allowing an object to be saved to the db enables flexibility to do much more with raw sql, including adding indices on metadata fields. Is there a strong reason why stringifying before saving to the DB should be required? This PR provides the option to directly write the incoming Record<string, any> to the db, so that the flexibility extends to direct db queries as well, instead of forcing the flexibility to exist only within application code. I'd be happy to update the docs as well to describe the behavior here, but I'm unsure if that should be a commit in this PR or a separate one with a docs header. LMK. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added an option to control whether organization metadata is stringified before saving to the database, allowing direct storage of objects for more flexible querying. - **New Features** - Added the stringifyOrganizationMetadata option to OrganizationOptions. - Metadata can now be stored as either JSON strings or raw objects based on this setting. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 21:45:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#30729