@contember/schema-definition 2.1.0-alpha.26 → 2.1.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/schema-definition",
3
- "version": "2.1.0-alpha.26",
3
+ "version": "2.1.0-alpha.28",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/production/index.js",
6
6
  "typings": "./dist/types/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@contember/schema": "2.1.0-alpha.26",
27
- "@contember/schema-utils": "2.1.0-alpha.26",
26
+ "@contember/schema": "2.1.0-alpha.28",
27
+ "@contember/schema-utils": "2.1.0-alpha.28",
28
28
  "reflect-metadata": "^0.2.2",
29
29
  "fast-deep-equal": "^3.1.3"
30
30
  },
@@ -1,17 +1,21 @@
1
1
  import { extendEntity } from './extensions'
2
2
  import { DecoratorFunction } from '../../utils'
3
+ import { Model } from '@contember/schema'
3
4
 
4
- export type IndexOptions<T> = { fields: (keyof T)[] }
5
+ export type IndexOptions<T> = {
6
+ fields: (keyof T)[]
7
+ method?: Model.IndexMethod
8
+ }
5
9
  export function Index<T>(options: IndexOptions<T>): DecoratorFunction<T>
6
10
  export function Index<T>(...fields: (keyof T)[]): DecoratorFunction<T>
7
11
  export function Index<T>(options: IndexOptions<T> | keyof T, ...args: (keyof T)[]): DecoratorFunction<T> {
8
12
  return extendEntity(({ entity }) => {
9
- const fields = (typeof options !== 'object' ? [options, ...args] : options.fields) as string[]
13
+ const indexDef = (typeof options !== 'object' ? { fields: [options, ...args] } : options) as { fields: string[]; method?: Model.IndexMethod }
10
14
  return {
11
15
  ...entity,
12
16
  indexes: [
13
17
  ...entity.indexes,
14
- { fields },
18
+ indexDef,
15
19
  ],
16
20
  }
17
21
  })
@@ -13,6 +13,7 @@ export type UniqueOptions<T> = {
13
13
  | {
14
14
  index: true
15
15
  nulls?: Model.NullsDistinctBehaviour
16
+ method?: Model.IndexMethod
16
17
  }
17
18
  )
18
19
  export function Unique<T>(options: UniqueOptions<T>): DecoratorFunction<T>