Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

The adapter hardcoded casbin_rule as the MongoDB collection name, preventing users from following their own database naming conventions.

Changes

  • MongooseAdapterOptions interface: Added optional collectionName parameter
  • Schema function: Accepts custom collection name, falls back to default
  • Adapter constructor: Passes custom collection name to both schema and model creation
  • Unit tests: Verify default behavior and custom collection name functionality
  • Documentation: Added usage example and configuration section

Usage

const adapter = await MongooseAdapter.newAdapter(
  'mongodb://localhost:27017',
  {},
  { collectionName: 'casbinRule' }  // Use camelCase or any naming convention
);

When collectionName is omitted, the adapter uses casbin_rule as before.

Original prompt

This section details on the original issue you should resolve

<issue_title>Possibility to set collection name for the adapter</issue_title>
<issue_description>It would be great to be able to set collection name as an option in adapterOptions

Currently adapter is using hardcoded casbin_rule name

We'd like to use camelCase to be in line with our db naming convention
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@hsluoyz
Copy link
Member

hsluoyz commented Dec 9, 2025

@nodece @Shivansh-yadav13 please review

@mserico mserico marked this pull request as ready for review December 9, 2025 15:26
Co-authored-by: mserico <140243407+mserico@users.noreply.github.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits December 9, 2025 15:32
Co-authored-by: mserico <140243407+mserico@users.noreply.github.com>
Co-authored-by: mserico <140243407+mserico@users.noreply.github.com>
Copilot AI changed the title [WIP] Add possibility to set collection name for adapter Add configurable collection name via adapterOptions Dec 9, 2025
Copilot AI requested a review from mserico December 9, 2025 15:38
@mserico mserico changed the title Add configurable collection name via adapterOptions feat: add configurable collection name via adapterOptions Dec 9, 2025
@mserico mserico merged commit 5fac73a into master Dec 9, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possibility to set collection name for the adapter

4 participants