bigal 12.1.4 → 13.0.0-beta1

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.
Files changed (213) hide show
  1. package/.devcontainer/devcontainer.json +16 -0
  2. package/.husky/pre-commit +4 -0
  3. package/.prettierrc.cjs +34 -0
  4. package/CHANGELOG.md +9 -0
  5. package/dist/index.cjs +2626 -0
  6. package/dist/index.d.cts +892 -0
  7. package/dist/index.d.mts +892 -0
  8. package/dist/index.d.ts +892 -0
  9. package/dist/index.mjs +2605 -0
  10. package/eslint.config.mjs +25 -0
  11. package/package.json +46 -37
  12. package/tsconfig.build.json +7 -0
  13. package/Entity.d.ts +0 -16
  14. package/Entity.js +0 -13
  15. package/Entity.js.map +0 -1
  16. package/IReadonlyRepository.d.ts +0 -36
  17. package/IReadonlyRepository.js +0 -3
  18. package/IReadonlyRepository.js.map +0 -1
  19. package/IRepository.d.ts +0 -99
  20. package/IRepository.js +0 -3
  21. package/IRepository.js.map +0 -1
  22. package/ReadonlyRepository.d.ts +0 -69
  23. package/ReadonlyRepository.js +0 -687
  24. package/ReadonlyRepository.js.map +0 -1
  25. package/Repository.d.ts +0 -69
  26. package/Repository.js +0 -171
  27. package/Repository.js.map +0 -1
  28. package/SqlHelper.d.ts +0 -144
  29. package/SqlHelper.js +0 -1081
  30. package/SqlHelper.js.map +0 -1
  31. package/decorators/ColumnBaseOptions.d.ts +0 -10
  32. package/decorators/ColumnBaseOptions.js +0 -3
  33. package/decorators/ColumnBaseOptions.js.map +0 -1
  34. package/decorators/ColumnCollectionOptions.d.ts +0 -15
  35. package/decorators/ColumnCollectionOptions.js +0 -3
  36. package/decorators/ColumnCollectionOptions.js.map +0 -1
  37. package/decorators/ColumnModelOptions.d.ts +0 -7
  38. package/decorators/ColumnModelOptions.js +0 -3
  39. package/decorators/ColumnModelOptions.js.map +0 -1
  40. package/decorators/ColumnTypeOptions.d.ts +0 -21
  41. package/decorators/ColumnTypeOptions.js +0 -3
  42. package/decorators/ColumnTypeOptions.js.map +0 -1
  43. package/decorators/TableOptions.d.ts +0 -14
  44. package/decorators/TableOptions.js +0 -3
  45. package/decorators/TableOptions.js.map +0 -1
  46. package/decorators/column.d.ts +0 -9
  47. package/decorators/column.js +0 -93
  48. package/decorators/column.js.map +0 -1
  49. package/decorators/createDateColumn.d.ts +0 -6
  50. package/decorators/createDateColumn.js +0 -50
  51. package/decorators/createDateColumn.js.map +0 -1
  52. package/decorators/index.d.ts +0 -6
  53. package/decorators/index.js +0 -23
  54. package/decorators/index.js.map +0 -1
  55. package/decorators/primaryColumn.d.ts +0 -8
  56. package/decorators/primaryColumn.js +0 -66
  57. package/decorators/primaryColumn.js.map +0 -1
  58. package/decorators/table.d.ts +0 -5
  59. package/decorators/table.js +0 -40
  60. package/decorators/table.js.map +0 -1
  61. package/decorators/updateDateColumn.d.ts +0 -6
  62. package/decorators/updateDateColumn.js +0 -51
  63. package/decorators/updateDateColumn.js.map +0 -1
  64. package/decorators/versionColumn.d.ts +0 -6
  65. package/decorators/versionColumn.js +0 -51
  66. package/decorators/versionColumn.js.map +0 -1
  67. package/errors/QueryError.d.ts +0 -8
  68. package/errors/QueryError.js +0 -13
  69. package/errors/QueryError.js.map +0 -1
  70. package/errors/index.d.ts +0 -1
  71. package/errors/index.js +0 -18
  72. package/errors/index.js.map +0 -1
  73. package/index.d.ts +0 -35
  74. package/index.js +0 -220
  75. package/index.js.map +0 -1
  76. package/metadata/ColumnBaseMetadata.d.ts +0 -93
  77. package/metadata/ColumnBaseMetadata.js +0 -19
  78. package/metadata/ColumnBaseMetadata.js.map +0 -1
  79. package/metadata/ColumnCollectionMetadata.d.ts +0 -36
  80. package/metadata/ColumnCollectionMetadata.js +0 -63
  81. package/metadata/ColumnCollectionMetadata.js.map +0 -1
  82. package/metadata/ColumnMetadata.d.ts +0 -4
  83. package/metadata/ColumnMetadata.js +0 -3
  84. package/metadata/ColumnMetadata.js.map +0 -1
  85. package/metadata/ColumnModelMetadata.d.ts +0 -18
  86. package/metadata/ColumnModelMetadata.js +0 -43
  87. package/metadata/ColumnModelMetadata.js.map +0 -1
  88. package/metadata/ColumnModifierMetadata.d.ts +0 -46
  89. package/metadata/ColumnModifierMetadata.js +0 -3
  90. package/metadata/ColumnModifierMetadata.js.map +0 -1
  91. package/metadata/ColumnTypeMetadata.d.ts +0 -43
  92. package/metadata/ColumnTypeMetadata.js +0 -26
  93. package/metadata/ColumnTypeMetadata.js.map +0 -1
  94. package/metadata/MetadataStorage.d.ts +0 -13
  95. package/metadata/MetadataStorage.js +0 -19
  96. package/metadata/MetadataStorage.js.map +0 -1
  97. package/metadata/ModelMetadata.d.ts +0 -36
  98. package/metadata/ModelMetadata.js +0 -81
  99. package/metadata/ModelMetadata.js.map +0 -1
  100. package/metadata/index.d.ts +0 -10
  101. package/metadata/index.js +0 -33
  102. package/metadata/index.js.map +0 -1
  103. package/query/Comparer.d.ts +0 -1
  104. package/query/Comparer.js +0 -3
  105. package/query/Comparer.js.map +0 -1
  106. package/query/CountArgs.d.ts +0 -7
  107. package/query/CountArgs.js +0 -3
  108. package/query/CountArgs.js.map +0 -1
  109. package/query/CountResult.d.ts +0 -5
  110. package/query/CountResult.js +0 -3
  111. package/query/CountResult.js.map +0 -1
  112. package/query/CreateOptions.d.ts +0 -9
  113. package/query/CreateOptions.js +0 -3
  114. package/query/CreateOptions.js.map +0 -1
  115. package/query/CreateUpdateOptions.d.ts +0 -4
  116. package/query/CreateUpdateOptions.js +0 -3
  117. package/query/CreateUpdateOptions.js.map +0 -1
  118. package/query/DeleteOptions.d.ts +0 -12
  119. package/query/DeleteOptions.js +0 -3
  120. package/query/DeleteOptions.js.map +0 -1
  121. package/query/DestroyResult.d.ts +0 -5
  122. package/query/DestroyResult.js +0 -3
  123. package/query/DestroyResult.js.map +0 -1
  124. package/query/DoNotReturnRecords.d.ts +0 -3
  125. package/query/DoNotReturnRecords.js +0 -3
  126. package/query/DoNotReturnRecords.js.map +0 -1
  127. package/query/FindArgs.d.ts +0 -6
  128. package/query/FindArgs.js +0 -3
  129. package/query/FindArgs.js.map +0 -1
  130. package/query/FindOneArgs.d.ts +0 -11
  131. package/query/FindOneArgs.js +0 -3
  132. package/query/FindOneArgs.js.map +0 -1
  133. package/query/FindOneResult.d.ts +0 -12
  134. package/query/FindOneResult.js +0 -3
  135. package/query/FindOneResult.js.map +0 -1
  136. package/query/FindResult.d.ts +0 -15
  137. package/query/FindResult.js +0 -3
  138. package/query/FindResult.js.map +0 -1
  139. package/query/OnConflictOptions.d.ts +0 -25
  140. package/query/OnConflictOptions.js +0 -3
  141. package/query/OnConflictOptions.js.map +0 -1
  142. package/query/PaginateOptions.d.ts +0 -4
  143. package/query/PaginateOptions.js +0 -3
  144. package/query/PaginateOptions.js.map +0 -1
  145. package/query/PopulateArgs.d.ts +0 -13
  146. package/query/PopulateArgs.js +0 -3
  147. package/query/PopulateArgs.js.map +0 -1
  148. package/query/ReturnSelect.d.ts +0 -5
  149. package/query/ReturnSelect.js +0 -3
  150. package/query/ReturnSelect.js.map +0 -1
  151. package/query/Sort.d.ts +0 -15
  152. package/query/Sort.js +0 -3
  153. package/query/Sort.js.map +0 -1
  154. package/query/WhereQuery.d.ts +0 -21
  155. package/query/WhereQuery.js +0 -3
  156. package/query/WhereQuery.js.map +0 -1
  157. package/query/index.d.ts +0 -15
  158. package/query/index.js +0 -32
  159. package/query/index.js.map +0 -1
  160. package/types/ClassLike.d.ts +0 -8
  161. package/types/ClassLike.js +0 -3
  162. package/types/ClassLike.js.map +0 -1
  163. package/types/CreateUpdateParams.d.ts +0 -9
  164. package/types/CreateUpdateParams.js +0 -3
  165. package/types/CreateUpdateParams.js.map +0 -1
  166. package/types/EntityPrimitiveOrId.d.ts +0 -2
  167. package/types/EntityPrimitiveOrId.js +0 -3
  168. package/types/EntityPrimitiveOrId.js.map +0 -1
  169. package/types/ExcludeEntityCollections.d.ts +0 -5
  170. package/types/ExcludeEntityCollections.js +0 -3
  171. package/types/ExcludeEntityCollections.js.map +0 -1
  172. package/types/ExcludeFunctions.d.ts +0 -4
  173. package/types/ExcludeFunctions.js +0 -3
  174. package/types/ExcludeFunctions.js.map +0 -1
  175. package/types/GetValueType.d.ts +0 -1
  176. package/types/GetValueType.js +0 -3
  177. package/types/GetValueType.js.map +0 -1
  178. package/types/IncludeFunctions.d.ts +0 -4
  179. package/types/IncludeFunctions.js +0 -3
  180. package/types/IncludeFunctions.js.map +0 -1
  181. package/types/IsValueOfType.d.ts +0 -1
  182. package/types/IsValueOfType.js +0 -3
  183. package/types/IsValueOfType.js.map +0 -1
  184. package/types/OmitEntityCollections.d.ts +0 -7
  185. package/types/OmitEntityCollections.js +0 -3
  186. package/types/OmitEntityCollections.js.map +0 -1
  187. package/types/OmitFunctions.d.ts +0 -7
  188. package/types/OmitFunctions.js +0 -3
  189. package/types/OmitFunctions.js.map +0 -1
  190. package/types/PickAsType.d.ts +0 -3
  191. package/types/PickAsType.js +0 -3
  192. package/types/PickAsType.js.map +0 -1
  193. package/types/PickByValueType.d.ts +0 -5
  194. package/types/PickByValueType.js +0 -3
  195. package/types/PickByValueType.js.map +0 -1
  196. package/types/PickFunctions.d.ts +0 -4
  197. package/types/PickFunctions.js +0 -3
  198. package/types/PickFunctions.js.map +0 -1
  199. package/types/Populated.d.ts +0 -9
  200. package/types/Populated.js +0 -3
  201. package/types/Populated.js.map +0 -1
  202. package/types/QueryResult.d.ts +0 -9
  203. package/types/QueryResult.js +0 -3
  204. package/types/QueryResult.js.map +0 -1
  205. package/types/QueryResultOptionalPopulated.d.ts +0 -9
  206. package/types/QueryResultOptionalPopulated.js +0 -3
  207. package/types/QueryResultOptionalPopulated.js.map +0 -1
  208. package/types/QueryResultPopulated.d.ts +0 -9
  209. package/types/QueryResultPopulated.js +0 -3
  210. package/types/QueryResultPopulated.js.map +0 -1
  211. package/types/index.d.ts +0 -17
  212. package/types/index.js +0 -34
  213. package/types/index.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ import { defaultConfig } from 'eslint-config-decent';
2
+ import tsEslint from 'typescript-eslint';
3
+
4
+ export default tsEslint.config(
5
+ ...defaultConfig(),
6
+ {
7
+ files: ['**/*.mjs'],
8
+ rules: {
9
+ '@typescript-eslint/no-unsafe-call': 'off',
10
+ '@typescript-eslint/no-unsafe-member-access': 'off',
11
+ },
12
+ },
13
+ {
14
+ files: ['**/*.ts'],
15
+ rules: {
16
+ '@typescript-eslint/no-invalid-void-type': 'off',
17
+ },
18
+ },
19
+ {
20
+ files: ['tests/**/*.ts'],
21
+ rules: {
22
+ '@typescript-eslint/no-non-null-assertion': 'off',
23
+ },
24
+ },
25
+ );
package/package.json CHANGED
@@ -1,9 +1,23 @@
1
1
  {
2
2
  "name": "bigal",
3
- "version": "12.1.4",
3
+ "version": "13.0.0-beta1",
4
4
  "description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
7
21
  "keywords": [
8
22
  "orm",
9
23
  "postgres",
@@ -19,66 +33,61 @@
19
33
  "node": ">=18"
20
34
  },
21
35
  "dependencies": {
22
- "@types/lodash": "^4.17.0",
23
- "@types/pg": "^8.11.4",
24
36
  "lodash": "^4.17.21",
25
- "pg": "^8.11.5",
26
- "postgres-pool": "^8.1.5"
37
+ "pg": "^8.12.0",
38
+ "postgres-pool": "^9.0.0-beta2"
27
39
  },
28
40
  "devDependencies": {
29
41
  "@faker-js/faker": "^8.4.1",
30
- "@types/chai": "^4.3.14",
31
- "@types/mocha": "10.0.6",
42
+ "@types/chai": "^4.3.16",
43
+ "@types/lodash": "^4.17.6",
44
+ "@types/mocha": "10.0.7",
32
45
  "@types/node": ">=20",
33
- "@typescript-eslint/eslint-plugin": "^7.6.0",
34
- "@typescript-eslint/parser": "^7.6.0",
35
- "chai": "^4.4.1",
36
- "eslint": "^8.57.0",
37
- "eslint-config-airbnb-base": "^15.0.0",
38
- "eslint-config-airbnb-typescript": "^18.0.0",
39
- "eslint-config-prettier": "^9.1.0",
40
- "eslint-plugin-import": "^2.29.1",
41
- "eslint-plugin-jsdoc": "^48.2.3",
42
- "eslint-plugin-mocha": "10.4.1",
43
- "eslint-plugin-prettier": "^5.1.3",
44
- "eslint-plugin-promise": "^6.1.1",
45
- "eslint-plugin-security": "^2.1.1",
46
+ "@types/pg": "^8.11.6",
47
+ "chai": "^5.1.1",
48
+ "eslint": "^9.6.0",
49
+ "eslint-config-decent": "^1.2.2",
46
50
  "husky": "^9.0.11",
47
- "lint-staged": "^15.2.2",
48
- "markdownlint-cli": "^0.39.0",
49
- "mocha": "^10.4.0",
51
+ "lint-staged": "^15.2.7",
52
+ "markdownlint-cli": "^0.41.0",
53
+ "mocha": "^10.5.2",
50
54
  "npm-run-all": "^4.1.5",
51
55
  "pinst": "^3.0.0",
52
- "prettier": "^3.2.5",
53
- "rimraf": "^5.0.5",
56
+ "prettier": "^3.3.2",
54
57
  "strict-event-emitter-types": "^2.0.0",
55
58
  "ts-mockito": "^2.6.1",
56
59
  "ts-node": "^10.9.2",
57
- "typescript": "^5.4.4"
60
+ "typescript": "^5.5.3",
61
+ "typescript-eslint": "^8.0.0-alpha.39",
62
+ "unbuild": "^2.0.0"
58
63
  },
59
64
  "scripts": {
60
- "check:types": "tsc -p tsconfig.lint.json --noEmit",
61
- "prebuild": "rimraf dist",
62
- "build": "tsc",
63
- "test": "mocha -r ts-node/register tests/**/*.tests.ts",
65
+ "build": "unbuild",
66
+ "check:types": "tsc --noEmit --skipLibCheck",
67
+ "test": "mocha --loader=ts-node/esm tests/**/*.tests.ts",
64
68
  "lint:markdown": "prettier --write '*.md' '!(node_modules|dist)/**/*.md' && markdownlint '*.md' '!(node_modules|dist)/**/*.md' --config=.github/linters/.markdown-lint.yml --fix",
65
- "lint:code": "eslint --fix --ext .ts src tests",
69
+ "lint:code": "eslint --fix",
66
70
  "lint": "run-p lint:*",
67
71
  "lint-staged": "lint-staged",
68
- "dist": "if [ -d \"src\" ]; then rm -rf dist && npm run build && npm run lint && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp LICENSE dist && cp .npmignore dist && cd dist && npm publish; fi",
69
- "beta": "if [ -d \"src\" ]; then rm -rf dist && npm run build && npm run lint && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp LICENSE dist && cp .npmignore dist && cd dist && npm publish --tag beta; fi",
70
- "prepublishOnly": "if [ -d \"src\" ]; then echo \"Please use: npm run dist\" && exit 125; fi && pinst --disable",
72
+ "beta": "npm publish --tag beta",
73
+ "prepublishOnly": "npm run lint && npm run test && npm run build && pinst --disable",
71
74
  "postpublish": "pinst --enable",
72
75
  "prepare": "husky"
73
76
  },
74
77
  "lint-staged": {
75
78
  "*.md": [
76
- "prettier --write",
79
+ "prettier --write --cache",
77
80
  "markdownlint --config=.github/linters/.markdown-lint.yml --fix"
78
81
  ],
79
82
  "*.js": [
80
83
  "eslint --fix"
81
84
  ],
85
+ "*.cjs": [
86
+ "eslint --fix"
87
+ ],
88
+ "*.mjs": [
89
+ "eslint --fix"
90
+ ],
82
91
  "*.ts": [
83
92
  "eslint --fix"
84
93
  ]
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src"
5
+ },
6
+ "include": ["src"]
7
+ }
package/Entity.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { CreateUpdateParams } from './types';
2
- export type EntityFieldValue = boolean[] | Date | number[] | Record<string, unknown> | string[] | boolean | number | string | unknown | null;
3
- export declare abstract class Entity {
4
- abstract id: unknown;
5
- static beforeCreate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
6
- static beforeUpdate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
7
- }
8
- export interface NotEntityBrand {
9
- _notEntityBrand: void;
10
- }
11
- export type NotEntity<T> = NotEntityBrand & T;
12
- export interface EntityStatic<T extends Entity> {
13
- beforeCreate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
14
- beforeUpdate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
15
- new (): T;
16
- }
package/Entity.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Entity = void 0;
4
- class Entity {
5
- static beforeCreate(values) {
6
- return values;
7
- }
8
- static beforeUpdate(values) {
9
- return values;
10
- }
11
- }
12
- exports.Entity = Entity;
13
- //# sourceMappingURL=Entity.js.map
package/Entity.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Entity.js","sourceRoot":"./","sources":["Entity.ts"],"names":[],"mappings":";;;AAKA,MAAsB,MAAM;IAGnB,MAAM,CAAC,YAAY,CAAC,MAAkC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,MAAkC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAVD,wBAUC"}
@@ -1,36 +0,0 @@
1
- import type { Entity } from './Entity';
2
- import type { ModelMetadata } from './metadata';
3
- import type { CountResult, FindArgs, FindOneArgs, FindOneResult, FindResult, WhereQuery } from './query';
4
- import type { CountArgs } from './query/CountArgs';
5
- import type { QueryResult } from './types';
6
- export interface IReadonlyRepository<T extends Entity> {
7
- readonly model: ModelMetadata<T>;
8
- /**
9
- * Gets a single object
10
- * @param {object} [args] - Arguments
11
- * @param {string[]} [args.select] - Array of model property names to return from the query.
12
- * @param {object} [args.where] - Object representing the where query
13
- * @param {string|object|string[]|object[]} [args.sort] - Property name(s) to sort by
14
- * @param {object} [args.pool] - Override the db pool to use for the query
15
- */
16
- findOne<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | 'id'>>>(args: FindOneArgs<T, K> | WhereQuery<T>): FindOneResult<T, TReturn>;
17
- /**
18
- * Gets a collection of objects
19
- * @param {object} [args] - Arguments
20
- * @param {string[]} [args.select] - Array of model property names to return from the query.
21
- * @param {object} [args.where] - Object representing the where query
22
- * @param {string|object|string[]|object[]} [args.sort] - Property name(s) to sort by
23
- * @param {string|number} [args.skip] - Number of records to skip
24
- * @param {string|number} [args.limit] - Number of results to return
25
- * @param {object} [args.pool] - Override the db pool to use for the query
26
- */
27
- find<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | 'id'>>>(args: FindArgs<T, K> | WhereQuery<T>): FindResult<T, TReturn>;
28
- /**
29
- * Gets a count of rows matching the where query
30
- * @param {object} [args] - Arguments
31
- * @param {object} [args.where] - Object representing the where query
32
- * @param {object} [args.pool] - Override the db pool to use for the query
33
- * @returns {number} Number of records matching the where criteria
34
- */
35
- count(args?: CountArgs<T> | WhereQuery<T>): CountResult<T>;
36
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IReadonlyRepository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IReadonlyRepository.js","sourceRoot":"./","sources":["IReadonlyRepository.ts"],"names":[],"mappings":""}
package/IRepository.d.ts DELETED
@@ -1,99 +0,0 @@
1
- import type { Entity } from './Entity';
2
- import type { IReadonlyRepository } from './IReadonlyRepository';
3
- import type { CreateUpdateOptions, //
4
- DeleteOptions, DestroyResult, DoNotReturnRecords, ReturnSelect, WhereQuery } from './query';
5
- import type { CreateOptions } from './query/CreateOptions';
6
- import type { OnConflictOptions } from './query/OnConflictOptions';
7
- import type { CreateUpdateParams, QueryResult } from './types';
8
- export interface IRepository<T extends Entity> extends IReadonlyRepository<T> {
9
- /**
10
- * Creates an object using the specified values
11
- * @param {object} values - Values to insert as multiple new objects.
12
- * @param {object} [options]
13
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
14
- * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
15
- * @returns {object}
16
- */
17
- create(values: CreateUpdateParams<T>, options?: OnConflictOptions<T> | (Partial<OnConflictOptions<T>> & ReturnSelect<T>)): Promise<QueryResult<T>>;
18
- /**
19
- * Creates an object or objects using the specified values
20
- * @param {object|object[]} values - Values to insert as multiple new objects.
21
- * @param {object} options
22
- * @param {boolean} options.returnRecords - Determines if inserted records should be returned
23
- * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
24
- * @returns {void}
25
- */
26
- create(values: CreateUpdateParams<T> | CreateUpdateParams<T>[], options: DoNotReturnRecords & Partial<OnConflictOptions<T>>): Promise<void>;
27
- /**
28
- * Creates objects using the specified values
29
- * @param {object[]} values - Values to insert as multiple new objects.
30
- * @param {object} [options]
31
- * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
32
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
33
- * @returns {object[]}
34
- */
35
- create(values: CreateUpdateParams<T>[], options?: (OnConflictOptions<T> & Partial<ReturnSelect<T>>) | (Partial<OnConflictOptions<T>> & ReturnSelect<T>)): Promise<QueryResult<T>[]>;
36
- /**
37
- * Creates an object using the specified values
38
- * @param {object|object[]} values - Values to insert as a new object. If an array is specified, multiple rows will be inserted
39
- * @param {object} [options]
40
- * @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
41
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
42
- * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
43
- * @returns {object|object[]|void} Return value from the db
44
- */
45
- create(values: CreateUpdateParams<T> | CreateUpdateParams<T>[], options?: CreateOptions<T>): Promise<QueryResult<T> | QueryResult<T>[] | void>;
46
- /**
47
- * Updates object(s) matching the where query, with the specified values
48
- * @param {object} where - Object representing the where query
49
- * @param {object} values - Values to update
50
- * @param {object} options
51
- * @param {boolean} options.returnRecords - Determines if inserted records should be returned
52
- * @param {{returnRecords: false}} options
53
- * @returns {void}
54
- */
55
- update(where: WhereQuery<T>, values: CreateUpdateParams<T>, options: DoNotReturnRecords): Promise<void>;
56
- /**
57
- * Updates object(s) matching the where query, with the specified values
58
- * @param {object} where - Object representing the where query
59
- * @param {object} values - Values to update
60
- * @param {object} [options] - Values to update
61
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
62
- * @returns {object[]}
63
- */
64
- update(where: WhereQuery<T>, values: CreateUpdateParams<T>, options?: ReturnSelect<T>): Promise<QueryResult<T>[]>;
65
- /**
66
- * Updates object(s) matching the where query, with the specified values
67
- * @param {object} where - Object representing the where query
68
- * @param {object} values - Values to update
69
- * @param {object} [options]
70
- * @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
71
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
72
- * @returns {object[]|void} Return values from the db or `true` if returnRecords=false
73
- */
74
- update(where: WhereQuery<T>, values: CreateUpdateParams<T>, options?: CreateUpdateOptions<T>): Promise<QueryResult<T>[] | void>;
75
- /**
76
- * Destroys object(s) matching the where query
77
- * @param {object} [where] - Object representing the where query
78
- * @returns {void}
79
- */
80
- destroy(where?: WhereQuery<T>): DestroyResult<T, void>;
81
- /**
82
- * Destroys object(s) matching the where query
83
- * @param {object} where - Object representing the where query
84
- * @param {object} options - Determines if inserted records should be returned
85
- * @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
86
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
87
- * @returns {object[]}
88
- */
89
- destroy(where: WhereQuery<T>, options: DeleteOptions<T>): DestroyResult<T, QueryResult<T>[]>;
90
- /**
91
- * Destroys object(s) matching the where query
92
- * @param {object} where - Object representing the where query
93
- * @param {object} [options]
94
- * @param {boolean} [options.returnRecords=false] - Determines if inserted records should be returned
95
- * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
96
- * @returns {object[]|void} `void` or records affected if returnRecords=true
97
- */
98
- destroy<TOptions extends DeleteOptions<T> = DeleteOptions<T>>(where: WhereQuery<T>, options?: TOptions): DestroyResult<T, TOptions extends DeleteOptions<T> ? void : QueryResult<T>[]>;
99
- }
package/IRepository.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IRepository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IRepository.js","sourceRoot":"./","sources":["IRepository.ts"],"names":[],"mappings":""}
@@ -1,69 +0,0 @@
1
- import type { Pool } from 'postgres-pool';
2
- import type { Entity, EntityStatic } from './Entity';
3
- import type { IReadonlyRepository } from './IReadonlyRepository';
4
- import type { IRepository } from './IRepository';
5
- import type { ModelMetadata } from './metadata';
6
- import type { CountResult, FindArgs, FindOneArgs, FindOneResult, FindResult, OrderBy, WhereQuery, SortObject } from './query';
7
- import type { CountArgs } from './query/CountArgs';
8
- import type { QueryResult, PickFunctions } from './types';
9
- export interface IRepositoryOptions<T extends Entity> {
10
- modelMetadata: ModelMetadata<T>;
11
- type: EntityStatic<T>;
12
- repositoriesByModelNameLowered: Record<string, IReadonlyRepository<Entity> | IRepository<Entity>>;
13
- pool: Pool;
14
- readonlyPool?: Pool;
15
- }
16
- interface Populate {
17
- propertyName: string;
18
- where?: WhereQuery<Entity>;
19
- select?: string[];
20
- sort?: SortObject<Entity> | string;
21
- skip?: number;
22
- limit?: number;
23
- pool?: Pool;
24
- }
25
- export declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepository<T> {
26
- private readonly _modelMetadata;
27
- protected _type: EntityStatic<T>;
28
- protected _pool: Pool;
29
- protected _readonlyPool: Pool;
30
- protected _repositoriesByModelNameLowered: Record<string, IReadonlyRepository<Entity> | IRepository<Entity>>;
31
- protected _floatProperties: string[];
32
- protected _intProperties: string[];
33
- constructor({ modelMetadata, type, pool, readonlyPool, repositoriesByModelNameLowered }: IRepositoryOptions<T>);
34
- get model(): ModelMetadata<T>;
35
- /**
36
- * Gets a single object
37
- * @param {object} [args] - Arguments
38
- * @param {string[]} [args.select] - Array of model property names to return from the query.
39
- * @param {object} [args.where] - Object representing the where query
40
- * @param {string|object} [args.sort] - Property name(s) to sort by
41
- */
42
- findOne<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindOneArgs<T, K> | WhereQuery<T>): FindOneResult<T, TReturn>;
43
- /**
44
- * Gets a collection of objects
45
- * @param {object} [args] - Arguments
46
- * @param {string[]} [args.select] - Array of model property names to return from the query.
47
- * @param {object} [args.where] - Object representing the where query
48
- * @param {string|object} [args.sort] - Property name(s) to sort by
49
- * @param {string|number} [args.skip] - Number of records to skip
50
- * @param {string|number} [args.limit] - Number of results to return
51
- */
52
- find<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindArgs<T, K> | WhereQuery<T>): FindResult<T, TReturn>;
53
- /**
54
- * Gets a count of rows matching the where query
55
- * @param {object} [args] - Arguments
56
- * @param {object} [args.where] - Object representing the where query
57
- * @param {object} [args.pool] - Override the db pool to use for the query
58
- * @returns {number} Number of records matching the where criteria
59
- */
60
- count(args?: CountArgs<T> | WhereQuery<T>): CountResult<T>;
61
- protected _buildInstance(row: Partial<QueryResult<T>>): QueryResult<T>;
62
- protected _buildInstances(rows: Partial<QueryResult<T>>[]): QueryResult<T>[];
63
- protected _convertSortsToOrderBy(sorts: SortObject<T> | string): OrderBy<T>[];
64
- protected populateFields(entities: QueryResult<T>[], populates: Populate[]): Promise<void>;
65
- private populateSingleAssociation;
66
- private populateOneManyCollection;
67
- private populateManyManyCollection;
68
- }
69
- export {};