Documents in organization related collections in MongoDB missing updatedAt timestamp #1701

Closed
opened 2026-03-13 08:57:27 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @cpolanish on GitHub (Aug 13, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Initialize an auth object with the organization plugin and MongoDB adapter and create an organization.

Current vs. Expected behavior

When a new organization is created, the records in MongoDB in the organization and member collections are missing the updatedAt timestamp. It has createdAt, but no updatedAt. Both timestamps should be included as they are in the base collections (user, account, session, etc).

What version of Better Auth are you using?

1.3.5

System info

Windows 11

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @cpolanish on GitHub (Aug 13, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Initialize an auth object with the organization plugin and MongoDB adapter and create an organization. ### Current vs. Expected behavior When a new organization is created, the records in MongoDB in the organization and member collections are missing the updatedAt timestamp. It has createdAt, but no updatedAt. Both timestamps should be included as they are in the base collections (user, account, session, etc). ### What version of Better Auth are you using? 1.3.5 ### System info ```bash Windows 11 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:57:27 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 13, 2025):

This is a known limitation in Better Auth v1.3.5: the organization and member collections only include createdAt, not updatedAt, because their schemas and the organization plugin logic do not define or update an updatedAt field. In contrast, base collections like user, account, and session have both timestamps because their schemas and internal adapter logic explicitly set and update updatedAt during create and update operations (sourceadapter logicbase schema example).

The MongoDB adapter does not automatically add or update updatedAt; it relies on the plugin or caller to provide these fields. Recent PRs confirm that updatedAt is still not handled for organization/member collections (PR #3941, PR #3906).

To work around this, you could extend the organization plugin or use hooks to manually add and update the updatedAt field during create and update operations for these collections, following the pattern used in the base collections. If you want to see this fixed upstream, the relevant changes would be in the organization plugin schema and adapter logic to ensure updatedAt is set and updated just like createdAt.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 13, 2025): <!-- Answer --> This is a known limitation in Better Auth v1.3.5: the organization and member collections only include createdAt, not updatedAt, because their schemas and the organization plugin logic do not define or update an updatedAt field. In contrast, base collections like user, account, and session have both timestamps because their schemas and internal adapter logic explicitly set and update updatedAt during create and update operations ([source](https://github.com/better-auth/better-auth/blob/98584f5f106da1f18b29a030b1537ea2931e28b4/packages/better-auth/src/plugins/organization/schema.ts), [adapter logic](https://github.com/better-auth/better-auth/blob/98584f5f106da1f18b29a030b1537ea2931e28b4/packages/better-auth/src/plugins/organization/adapter.ts), [base schema example](https://github.com/better-auth/better-auth/blob/98584f5f106da1f18b29a030b1537ea2931e28b4/packages/better-auth/src/db/schema.ts)). The MongoDB adapter does not automatically add or update updatedAt; it relies on the plugin or caller to provide these fields. Recent PRs confirm that updatedAt is still not handled for organization/member collections ([PR #3941](https://github.com/better-auth/better-auth/pull/3941), [PR #3906](https://github.com/better-auth/better-auth/pull/3906)). To work around this, you could extend the organization plugin or use hooks to manually add and update the updatedAt field during create and update operations for these collections, following the pattern used in the base collections. If you want to see this fixed upstream, the relevant changes would be in the organization plugin schema and adapter logic to ensure updatedAt is set and updated just like createdAt. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/426e408b-d893-4441-addf-cb0b363cc0da?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3986)
Author
Owner

@anmol-fzr commented on GitHub (Aug 14, 2025):

@dosu so i guess its pretty simple to fix all i need is to add updatedAt field to the adapter in organization for update call

@anmol-fzr commented on GitHub (Aug 14, 2025): @dosu so i guess its pretty simple to fix all i need is to add updatedAt field to the adapter in organization for update call
Author
Owner

@dosubot[bot] commented on GitHub (Nov 13, 2025):

Hi, @cpolanish. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that in Better Auth v1.3.5 using the MongoDB adapter, the organization and member collections lack the updatedAt timestamp, though createdAt is present.
  • This affects backend functionality on Windows 11.
  • The maintainer explained this is a known limitation because the organization plugin schema and adapter do not define or update updatedAt, unlike base collections.
  • Another user noted that fixing this likely requires adding updatedAt handling to the organization adapter's update call.
  • A suggested workaround is to manually add updatedAt via plugin extension or hooks.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Nov 13, 2025): Hi, @cpolanish. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that in Better Auth v1.3.5 using the MongoDB adapter, the organization and member collections lack the `updatedAt` timestamp, though `createdAt` is present. - This affects backend functionality on Windows 11. - The maintainer explained this is a known limitation because the organization plugin schema and adapter do not define or update `updatedAt`, unlike base collections. - Another user noted that fixing this likely requires adding `updatedAt` handling to the organization adapter's update call. - A suggested workaround is to manually add `updatedAt` via plugin extension or hooks. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1701