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

Multiple indexes, multi column indexes #27

Merged
merged 1 commit into from
Jul 15, 2020

Conversation

Jax-p
Copy link
Contributor

@Jax-p Jax-p commented Jul 7, 2020

As long as commit #26 allows you to create other Indexes aside Primary Key it doesn't allows you to create multiple indexes and indexes over multiple columns.

Multiple indexes:

old behavior (bug?):

Because of find() in model.ts found on row 46 only one column can be unique (or have a same index). Another definitions will be ignored.

new behavior

Every defined index will be used. It uses filter() and is iterating through the whole array of indexes instead of taking only first index.

Multicolumn indexes

You can create separate index for multiple columns.
For example: If you want to create unique combination of username and email, you can define it in your model:

@Index({ type: IndexType.UNIQUE, columns: ["username","email"] })
public myIndex!: Index;

Common improvments

  • indexes now labeled as a index (indexes) instead of key (keys)
  • defined interface for index Index
  • defined index type enum IndexType
  • defined index list with SQL translation columnIndexesList

@manyuanrong manyuanrong merged commit 4f3982d into manyuanrong:master Jul 15, 2020
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.

2 participants