This repository was archived by the owner on Jun 22, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const tableName = 'testentities';
2323before ( async ( ) => {
2424 const schema = ( await db ( ) ) . schema ;
2525 await Promise . resolve ( schema . dropTableIfExists ( tableName ) ) ;
26- await Promise . resolve ( schema . createTableIfNotExists ( tableName , async ( table ) => {
26+ await Promise . resolve ( schema . createTable ( tableName , async ( table ) => {
2727 table . string ( 'id' ) . unique ( ) ;
2828 table . string ( 'stringProp' ) ;
2929 table . float ( 'numberProp' ) ;
Original file line number Diff line number Diff line change 1+ import MissingEntityError from '@js-entity-repos/core/dist/errors/MissingEntityError' ;
12import ReplaceEntity from '@js-entity-repos/core/dist/signatures/ReplaceEntity' ;
23import Entity from '@js-entity-repos/core/dist/types/Entity' ;
34import FacadeConfig from '../FacadeConfig' ;
45import constructIdFilter from '../utils/constructIdFilter' ;
56import filterEntities from '../utils/filterEntities' ;
6- import getEntity from './getEntity' ;
77
88export default < E extends Entity > ( config : FacadeConfig < E > ) : ReplaceEntity < E > => {
99 return async ( { id, entity, filter = { } } ) => {
1010 const table = ( await config . db ( ) ) . table ( config . tableName ) ;
1111 const document = config . constructDocument ( { ...entity as any , id } ) ;
1212 const constructedFilter = constructIdFilter ( { id, filter, config } ) ;
13- await Promise . resolve ( filterEntities ( table , constructedFilter ) . update ( document ) ) ;
14- return getEntity < E > ( config ) ( { id, filter } ) ;
13+ const res = await Promise . resolve ( filterEntities ( table , constructedFilter ) . update ( document ) ) ;
14+ if ( ! res ) {
15+ throw new MissingEntityError ( config . entityName , id ) ;
16+ }
17+ return { entity } ;
1518 } ;
1619} ;
You can’t perform that action at this time.
0 commit comments