Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prepareIndexes() method to NewAdapterByDB() #64

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

toeydevelopment
Copy link
Contributor

I have discovered that when using the "NewAdapterByDB" function, it was missing the index preparation phase. To address this, I've decided to contribute by ensuring that this function performs the same initialization steps as other methods.

This pull request introduces several improvements to the MongoDB adapter:

  1. Refactored the NewAdapterByDB function:
    • Added a new 'collection' variable to directly access the specified collection.
    • Implemented error handling for a.prepareIndexes() call.
  2. Added a new prepareIndexes() method:
    • This method creates necessary indexes for improved query performance.
    • It's called during adapter initialization to ensure indexes are set up.
  3. Updated the open() method:
    • Added error handling for a.prepareIndexes() call.
  4. Modified the createIndex() call:
    • Updated to use the latest MongoDB driver syntax for index creation.
  5. Updated go.mod dependencies:
    • Added several new indirect dependencies, likely due to updates in the MongoDB driver or other related packages.

@CLAassistant
Copy link

CLAassistant commented Jul 21, 2024

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Coverage Status

coverage: 82.546% (-0.09%) from 82.636%
when pulling bf862ad on toeydevelopment:master
into 8560937 on casbin:master.

@hsluoyz hsluoyz changed the title Refactor MongoDB adapter and add prepareIndexes() method feat: add prepareIndexes() method to NewAdapterByDB() Jul 22, 2024
@hsluoyz hsluoyz merged commit 3a26594 into casbin:master Jul 22, 2024
4 of 5 checks passed
Copy link

🎉 This PR is included in version 3.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants