Skip to content

Commit

Permalink
Release v6.0.0
Browse files Browse the repository at this point in the history
* Update npms
* Change `.destroy()` to not return records by default. Use `.destroy({}, { returnRecords: true })` for previous behavior
* Return `void` instead of `boolean` when not returning records
  • Loading branch information
jgeurts committed Jan 6, 2021
1 parent c820d59 commit e715c03
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 112 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 6.0.0
* Update npms
* Change `.destroy()` to not return records by default. Use `.destroy({}, { returnRecords: true })` for previous behavior
* Return `void` instead of `boolean` when not returning records

### 5.0.3
* Update npms

Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bigal",
"version": "5.0.3",
"version": "6.0.0",
"description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -19,8 +19,8 @@
"node": ">=10"
},
"dependencies": {
"@types/lodash": "^4.14.165",
"@types/node": "^14.14.10",
"@types/lodash": "^4.14.167",
"@types/node": "^14.14.20",
"@types/pg": "^7.14.7",
"lodash": "4.17.20",
"pg": "8.5.1",
Expand All @@ -29,30 +29,30 @@
"devDependencies": {
"@types/chai": "^4.2.14",
"@types/faker": "^5.1.5",
"@types/mocha": "^8.0.4",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"@types/mocha": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"chai": "^4.2.0",
"eslint": "^7.14.0",
"eslint": "^7.17.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.7.8",
"eslint-plugin-jsdoc": "^30.7.13",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-prettier": "^3.2.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-security": "^1.4.0",
"faker": "^5.1.0",
"husky": "^5.0.4",
"husky": "^5.0.6",
"lint-staged": "^10.5.3",
"mocha": "^8.2.1",
"pinst": "^2.1.1",
"prettier": "^2.2.1",
"strict-event-emitter-types": "^2.0.0",
"ts-mockito": "^2.6.1",
"ts-node": "^9.1.0",
"typescript": "^4.1.2"
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},
"scripts": {
"build": "tsc",
Expand Down
54 changes: 28 additions & 26 deletions src/IRepository.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
import type { Entity } from './Entity';
import type { IReadonlyRepository } from './IReadonlyRepository';
import type {
CreateUpdateDeleteOptions, //
CreateUpdateOptions, //
DeleteOptions,
DestroyResult,
DoNotReturnRecords,
WhereQuery,
ReturnSelect,
} from './query';

export interface IRepository<T extends Entity> extends IReadonlyRepository<T> {
/**
* Creates a objects using the specified values
* @param {object} values - Values to insert as multiple new objects.
* @param {{returnRecords: false}} options
* @returns {boolean}
* @returns {object}
*/
create(values: Partial<T>, options?: CreateUpdateDeleteOptions): Promise<T>;
create(values: Partial<T>, options?: ReturnSelect): Promise<T>;

/**
* Creates a objects using the specified values
* @param {object|object[]} values - Values to insert as multiple new objects.
* @param {{returnRecords: false}} options
* @returns {boolean}
* @returns {void}
*/
create(values: Partial<T> | Partial<T>[], options: DoNotReturnRecords): Promise<boolean>;
create(values: Partial<T> | Partial<T>[], options: DoNotReturnRecords): Promise<void>;

/**
* Creates a objects using the specified values
* @param {object[]} values - Values to insert as multiple new objects.
* @param {object} [options]
* @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
* @returns {boolean}
* @returns {object[]}
*/
create(values: Partial<T>[], options?: CreateUpdateDeleteOptions): Promise<T[]>;
create(values: Partial<T>[], options?: ReturnSelect): Promise<T[]>;

/**
* Creates an object using the specified values
* @param {object|object[]} values - Values to insert as a new object. If an array is specified, multiple rows will be inserted
* @param {object} [options]
* @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
* @returns {object} Return value from the db
* @returns {object|object[]|void} Return value from the db
*/
create(values: Partial<T> | Partial<T>[], options?: CreateUpdateDeleteOptions): Promise<T | T[] | boolean>;
create(values: Partial<T> | Partial<T>[], options?: CreateUpdateOptions): Promise<T | T[] | void>;

/**
* Updates object(s) matching the where query, with the specified values
* @param {object} where - Object representing the where query
* @param {object} values - Values to update
* @param {{returnRecords: false}} options
* @returns {boolean}
* @returns {void}
*/
update(where: WhereQuery, values: Partial<T>, options: DoNotReturnRecords): Promise<boolean>;
update(where: WhereQuery, values: Partial<T>, options: DoNotReturnRecords): Promise<void>;

/**
* Updates object(s) matching the where query, with the specified values
Expand All @@ -60,9 +62,9 @@ export interface IRepository<T extends Entity> extends IReadonlyRepository<T> {
* @param {object} [options] - Values to update
* @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
* @returns {boolean}
* @returns {object[]}
*/
update(where: WhereQuery, values: Partial<T>, options?: CreateUpdateDeleteOptions): Promise<T[]>;
update(where: WhereQuery, values: Partial<T>, options?: ReturnSelect): Promise<T[]>;

/**
* Updates object(s) matching the where query, with the specified values
Expand All @@ -71,34 +73,34 @@ export interface IRepository<T extends Entity> extends IReadonlyRepository<T> {
* @param {object} [options]
* @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
* @returns {object[]} Return values from the db or `true` if returnRecords=false
* @returns {object[]|void} Return values from the db or `true` if returnRecords=false
*/
update(where: WhereQuery, values: Partial<T>, options?: CreateUpdateDeleteOptions): Promise<T[] | boolean>;
update(where: WhereQuery, values: Partial<T>, options?: CreateUpdateOptions): Promise<T[] | void>;

/**
* Destroys object(s) matching the where query
* @param {object} where - Object representing the where query
* @param {{returnRecords: false}} options
* @returns {boolean}
* @param {object} [where] - Object representing the where query
* @returns {void}
*/
destroy(where: WhereQuery, options: DoNotReturnRecords): DestroyResult<T, boolean>;
destroy(where?: WhereQuery): DestroyResult<T, void>;

/**
* Destroys object(s) matching the where query
* @param {object} where - Object representing the where query
* @param {object} [options] - Determines if inserted records should be returned
* @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
* @returns {boolean}
* @param {object} options - Determines if inserted records should be returned
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
* @returns {object[]}
*/
destroy(where?: WhereQuery, options?: CreateUpdateDeleteOptions): DestroyResult<T, T[]>;
destroy(where: WhereQuery, options: DeleteOptions): DestroyResult<T, T[]>;

/**
* Destroys object(s) matching the where query
* @param {object} where - Object representing the where query
* @param {object} [options]
* @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
* @param {boolean} [options.returnRecords=false] - Determines if inserted records should be returned
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
* @returns {object[]|boolean} Records affected or `true` if returnRecords=false
* @returns {object[]|void} `void` or records affected if returnRecords=true
*/
destroy(where: WhereQuery, options?: CreateUpdateDeleteOptions): DestroyResult<T, T[] | boolean>;
destroy<TOptions extends DeleteOptions = DeleteOptions>(where: WhereQuery, options?: TOptions): DestroyResult<T, TOptions extends DeleteOptions ? void : T[]>;
}
Loading

0 comments on commit e715c03

Please sign in to comment.