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

Add support for defining indexes on models #13

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

soderluk
Copy link

@soderluk soderluk commented May 7, 2022

Support ensuring indexes on collections. The Model.ensure_indexes()
function supports any indexing function that ArangoDB Collection
supports.

@lietu
Copy link

lietu commented May 9, 2022

Hey @soderluk ! 🙂

I think one way to tackle this a bit more cleanly would be to create classes for the different types of index, so HashIndex()? or AddHashIndex()? which take arguments, and you could then append them to a list instead of using magic string keys in a dict.

What do you think?

@lietu
Copy link

lietu commented May 9, 2022

So something like

indexes = [
  HashIndex(fields=["_from", "_to", "type"], unique=True)
]

@soderluk
Copy link
Author

soderluk commented May 9, 2022

@lietu Good idea! Will look into it :)

@soderluk
Copy link
Author

soderluk commented May 9, 2022

@lietu Made some updates to the PR. Please have a look, when you have the time.

@lietu
Copy link

lietu commented May 9, 2022

Overall I'd say I like it, with some luck @joakimnordling has the time to take a look at some point as well 👍

arangodantic/indexes.py Outdated Show resolved Hide resolved
arangodantic/indexes.py Outdated Show resolved Hide resolved
arangodantic/indexes.py Outdated Show resolved Hide resolved
arangodantic/models.py Outdated Show resolved Hide resolved
arangodantic/tests/conftest.py Show resolved Hide resolved
arangodantic/tests/test_model.py Show resolved Hide resolved
Support ensuring indexes on collections. The `Model.ensure_indexes()`
function supports any indexing function that ArangoDB Collection
supports.
Instead of using magic methods, set up index classes to handle all the
different indexing cases.
Mypy doesn't really understand what is returned from the add_*_index
function.
Fix the tests for ensuring indexes.

Make BaseIndex abstract base class, and make the add_index function as
abstract as well.

Move fields away from the BaseIndex to their respective sub-classes.
@soderluk
Copy link
Author

soderluk commented Nov 6, 2022

@joakimnordling Updated the tests and fixed a few things according to code review.

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.

3 participants