@piggly/ddd-toolkit
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -6,3 +6,2 @@ import { PaginateQuery } from '../types'; | ||
import Adapter from './Adapter'; | ||
import DatabaseContext from './DatabaseContext'; | ||
/** | ||
@@ -12,3 +11,3 @@ * @file A repository with default methods to manage entities. | ||
*/ | ||
export default abstract class Repository<Entity extends BaseEntity<any>, PersistenceRecord extends Record<string, any>> { | ||
export default abstract class Repository<Entity extends BaseEntity<any>, PersistenceRecord extends Record<string, any>, DatabaseContext> { | ||
/** | ||
@@ -23,3 +22,3 @@ * Database context. | ||
*/ | ||
protected _context: DatabaseContext; | ||
protected _database: DatabaseContext; | ||
/** | ||
@@ -26,0 +25,0 @@ * Constructor. |
@@ -17,3 +17,3 @@ "use strict"; | ||
*/ | ||
_context; | ||
_database; | ||
/** | ||
@@ -30,3 +30,3 @@ * Constructor. | ||
constructor(context) { | ||
this._context = context; | ||
this._database = context; | ||
} | ||
@@ -33,0 +33,0 @@ /** |
@@ -17,15 +17,4 @@ import DatabaseContext from './DatabaseContext'; | ||
*/ | ||
protected _context: DatabaseContext; | ||
protected _connection: DatabaseContext; | ||
/** | ||
* A map of repositories. | ||
* You may expose each repository individually. | ||
* | ||
* @type {Map<string, BaseRepository>} | ||
* @protected | ||
* @memberof UnitOfWork | ||
* @since 1.0.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
protected _repos: Map<string, BaseRepository<any, any>>; | ||
/** | ||
* Constructor. | ||
@@ -52,3 +41,3 @@ * Initiate all repositories with same context. | ||
*/ | ||
repository<Repository extends BaseRepository<any, any>>(name: string): Repository; | ||
abstract repository<Repository extends BaseRepository<any, any, any>>(name: string): Repository; | ||
/** | ||
@@ -55,0 +44,0 @@ * Begin a transaction in database context. |
@@ -17,15 +17,4 @@ "use strict"; | ||
*/ | ||
_context; | ||
_connection; | ||
/** | ||
* A map of repositories. | ||
* You may expose each repository individually. | ||
* | ||
* @type {Map<string, BaseRepository>} | ||
* @protected | ||
* @memberof UnitOfWork | ||
* @since 1.0.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
_repos = new Map(); | ||
/** | ||
* Constructor. | ||
@@ -42,22 +31,6 @@ * Initiate all repositories with same context. | ||
constructor(context) { | ||
this._context = context; | ||
this._connection = context; | ||
} | ||
/** | ||
* Get a repository by its name. | ||
* | ||
* @param {string} name | ||
* @returns {Repository} | ||
* @public | ||
* @memberof UnitOfWork | ||
* @since 1.0.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
repository(name) { | ||
if (this._repos.has(name) === false) { | ||
throw new Error(`Repository ${name} not found.`); | ||
} | ||
return this._repos.get(name); | ||
} | ||
} | ||
exports.default = UnitOfWork; | ||
//# sourceMappingURL=UnitOfWork.js.map |
@@ -6,3 +6,2 @@ import { PaginateQuery } from '../types'; | ||
import Adapter from './Adapter'; | ||
import DatabaseContext from './DatabaseContext'; | ||
/** | ||
@@ -12,3 +11,3 @@ * @file A repository with default methods to manage entities. | ||
*/ | ||
export default abstract class Repository<Entity extends BaseEntity<any>, PersistenceRecord extends Record<string, any>> { | ||
export default abstract class Repository<Entity extends BaseEntity<any>, PersistenceRecord extends Record<string, any>, DatabaseContext> { | ||
/** | ||
@@ -23,3 +22,3 @@ * Database context. | ||
*/ | ||
protected _context: DatabaseContext; | ||
protected _database: DatabaseContext; | ||
/** | ||
@@ -26,0 +25,0 @@ * Constructor. |
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
_context; | ||
_database; | ||
/** | ||
@@ -28,3 +28,3 @@ * Constructor. | ||
constructor(context) { | ||
this._context = context; | ||
this._database = context; | ||
} | ||
@@ -31,0 +31,0 @@ /** |
@@ -17,15 +17,4 @@ import DatabaseContext from './DatabaseContext'; | ||
*/ | ||
protected _context: DatabaseContext; | ||
protected _connection: DatabaseContext; | ||
/** | ||
* A map of repositories. | ||
* You may expose each repository individually. | ||
* | ||
* @type {Map<string, BaseRepository>} | ||
* @protected | ||
* @memberof UnitOfWork | ||
* @since 1.0.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
protected _repos: Map<string, BaseRepository<any, any>>; | ||
/** | ||
* Constructor. | ||
@@ -52,3 +41,3 @@ * Initiate all repositories with same context. | ||
*/ | ||
repository<Repository extends BaseRepository<any, any>>(name: string): Repository; | ||
abstract repository<Repository extends BaseRepository<any, any, any>>(name: string): Repository; | ||
/** | ||
@@ -55,0 +44,0 @@ * Begin a transaction in database context. |
@@ -15,15 +15,4 @@ /** | ||
*/ | ||
_context; | ||
_connection; | ||
/** | ||
* A map of repositories. | ||
* You may expose each repository individually. | ||
* | ||
* @type {Map<string, BaseRepository>} | ||
* @protected | ||
* @memberof UnitOfWork | ||
* @since 1.0.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
_repos = new Map(); | ||
/** | ||
* Constructor. | ||
@@ -40,21 +29,5 @@ * Initiate all repositories with same context. | ||
constructor(context) { | ||
this._context = context; | ||
this._connection = context; | ||
} | ||
/** | ||
* Get a repository by its name. | ||
* | ||
* @param {string} name | ||
* @returns {Repository} | ||
* @public | ||
* @memberof UnitOfWork | ||
* @since 1.0.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
repository(name) { | ||
if (this._repos.has(name) === false) { | ||
throw new Error(`Repository ${name} not found.`); | ||
} | ||
return this._repos.get(name); | ||
} | ||
} | ||
//# sourceMappingURL=UnitOfWork.js.map |
{ | ||
"name": "@piggly/ddd-toolkit", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "A bunch of tools to use Model-Driven Design and Domain-Driven Design architecture in a back-end application.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119638
3480