mongodb-adapter schema generation not supported #828

Closed
opened 2026-03-13 08:06:06 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @AsenCME on GitHub (Mar 11, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

As stated in the documentation, generating a mongodb schema is supposed to work.

Image

However, the following error appears when running the CLI:

preparing schema... 2025-03-11T11:56:36.206Z ERROR [Better Auth]: mongodb-adapter is not supported.

Looking the source code, it does indeed seem that only keysly, prisma and drizzle are supported and mongodb-adapter is not one of them despite the documentation saying otherwise.

Current vs. Expected behavior

Expected to work, throws error.

What version of Better Auth are you using?

1.23

Provide environment information

- OS: MacOS

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

Package, Documentation

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  ...
  database: mongodbAdapter(client.db()),
  ...
});

Additional context

No response

Originally created by @AsenCME on GitHub (Mar 11, 2025). ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce As stated in the documentation, generating a mongodb schema is supposed to work. <img width="923" alt="Image" src="https://github.com/user-attachments/assets/e86203a9-06c8-4491-a983-f550990e2078" /> However, the following error appears when running the CLI: ``` preparing schema... 2025-03-11T11:56:36.206Z ERROR [Better Auth]: mongodb-adapter is not supported. ``` Looking the source code, it does indeed seem that only keysly, prisma and drizzle are supported and mongodb-adapter is not one of them despite the documentation saying otherwise. ### Current vs. Expected behavior Expected to work, throws error. ### What version of Better Auth are you using? 1.23 ### Provide environment information ```bash - OS: MacOS ``` ### Which area(s) are affected? (Select all that apply) Package, Documentation ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ ... database: mongodbAdapter(client.db()), ... }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:06:06 -05:00
Author
Owner

@yohannesjoya commented on GitHub (Mar 11, 2025):

@AsenCME who is working on this? anyone started this?

@yohannesjoya commented on GitHub (Mar 11, 2025): @AsenCME who is working on this? anyone started this?
Author
Owner

@Bekacru commented on GitHub (Mar 12, 2025):

Better Auth supports mongodb, not mongoose. Since it doesn't rely on schemas, there's no need for schema generation.

@Bekacru commented on GitHub (Mar 12, 2025): Better Auth supports mongodb, not mongoose. Since it doesn't rely on schemas, there's no need for schema generation.
Author
Owner

@AsenCME commented on GitHub (Mar 12, 2025):

In my case, the error message states "... 'mongodb-adapter' not supported". I have followed the documentation in setting it up with the MongoDb connection string, like this:

import { betterAuth } from "better-auth";
const client = new MongoClient(process.env.MONGO_URI);

export const auth = betterAuth({
  ...
  database: mongodbAdapter(client.db()),
  ...
});

Better-auth is not connected to mongoose correctly.

@AsenCME commented on GitHub (Mar 12, 2025): In my case, the error message states "... 'mongodb-adapter' not supported". I have followed the documentation in setting it up with the MongoDb connection string, like this: ``` import { betterAuth } from "better-auth"; const client = new MongoClient(process.env.MONGO_URI); export const auth = betterAuth({ ... database: mongodbAdapter(client.db()), ... }); ``` Better-auth is not connected to mongoose correctly.
Author
Owner

@xorweak commented on GitHub (Mar 13, 2025):

I'm facing this problem too.

@xorweak commented on GitHub (Mar 13, 2025): I'm facing this problem too.
Author
Owner

@yohannesjoya commented on GitHub (Mar 13, 2025):

the work around that worked for me is using prisma and mongodb as provider

@yohannesjoya commented on GitHub (Mar 13, 2025): the work around that worked for me is using prisma and mongodb as provider
Author
Owner

@Muhamed-Ragab commented on GitHub (Mar 14, 2025):

I have the same error
I tried with mongoose and MongoDB client

@Muhamed-Ragab commented on GitHub (Mar 14, 2025): I have the same error I tried with mongoose and MongoDB client
Author
Owner

@jiaweing commented on GitHub (Mar 21, 2025):

I'm having the same issue while the docs said it's possible

@jiaweing commented on GitHub (Mar 21, 2025): I'm having the same issue while the docs said it's possible
Author
Owner

@Bekacru commented on GitHub (Mar 21, 2025):

If this issue is regarding the CLI, we recently removed mentions of generation related to MongoDB from the docs. MongoDB doesn't require a schema, and the CLI doesn't generate one either. The docs were incorrectly stating that it does.

@Bekacru commented on GitHub (Mar 21, 2025): If this issue is regarding the CLI, we recently removed mentions of `generation` related to MongoDB from the docs. MongoDB doesn't require a schema, and the CLI doesn't generate one either. The docs were incorrectly stating that it does.
Author
Owner

@xorweak commented on GitHub (Mar 22, 2025):

If this issue is regarding the CLI, we recently removed mentions of generation related to MongoDB from the docs. MongoDB doesn't require a schema, and the CLI doesn't generate one either. The docs were incorrectly stating that it does.

Oh, thanks for clarifying. Although mongodb does not require schema, it doesn't need to create indexes on the database?, I saw that you intend to add indexing support in the schema generation tool. Anyways, modifying the docs would be great to avoid confusion. 🤓😃

@xorweak commented on GitHub (Mar 22, 2025): > If this issue is regarding the CLI, we recently removed mentions of `generation` related to MongoDB from the docs. MongoDB doesn't require a schema, and the CLI doesn't generate one either. The docs were incorrectly stating that it does. Oh, thanks for clarifying. Although mongodb does not require schema, it doesn't need to create indexes on the database?, I saw that you intend to add indexing support in the schema generation tool. Anyways, modifying the docs would be great to avoid confusion. 🤓😃
Author
Owner

@arshx86 commented on GitHub (May 20, 2025):

okay it's not supported but then? we gotta create schemas ourself?

@arshx86 commented on GitHub (May 20, 2025): okay it's not supported but then? we gotta create schemas ourself?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#828