-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from twinlogix/feature/mongodb-indexes
feat: partially closes #415
- Loading branch information
Showing
14 changed files
with
307 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Update } from '../schemas/ast.types' | ||
import { AbstractSyntaxTree, AbstractScalars } from '../schemas/ast.types' | ||
import { CreateIndexesOptions, IndexDirection } from 'mongodb' | ||
|
||
type MongoDBIndex<AST extends AbstractSyntaxTree, Scalars extends AbstractScalars, K extends keyof AST> = { | ||
name: string | ||
specs: { [F in keyof (K extends string ? Update<K, AST, Scalars> : never)]?: IndexDirection } | ||
opts?: Omit<CreateIndexesOptions, 'name'> | ||
} | ||
|
||
type MongoEntities<AST extends AbstractSyntaxTree> = { | ||
[K in keyof AST]: AST[K]['driverSpecification']['type'] extends 'mongodb' ? K : never | ||
}[keyof AST] | ||
|
||
export type MongoDBIndexes<AST extends AbstractSyntaxTree, Scalars extends AbstractScalars> = { [K in MongoEntities<AST>]: MongoDBIndex<AST, Scalars, K>[] } | ||
export type Indexes<AST extends AbstractSyntaxTree = AbstractSyntaxTree, Scalars extends AbstractScalars = AbstractScalars> = { | ||
mongodb?: Partial<MongoDBIndexes<AST, Scalars>> | ||
} | ||
|
||
export type IndexesPlanResults = { | ||
mongodb: { | ||
toDelete: { collection: string; name: string }[] | ||
toCreate: { collection: string; name: string; specs: { [K in string]: IndexDirection }; opts?: Omit<CreateIndexesOptions, 'name'> }[] | ||
} | ||
//knexjs: never | ||
} | ||
|
||
export type IndexesApplyResults = { | ||
mongodb: { | ||
deleted: { collection: string; name: string }[] | ||
created: { collection: string; name: string; specs: { [K in string]: IndexDirection }; opts?: Omit<CreateIndexesOptions, 'name'> }[] | ||
failed: { collection: string; name: string; specs: { [K in string]: IndexDirection }; opts?: Omit<CreateIndexesOptions, 'name'>; error: unknown }[] | ||
} | ||
//knexjs: never | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.