-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RevertController): support revert in insert/update/delete
- Loading branch information
1 parent
d84a22e
commit e853646
Showing
11 changed files
with
418 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './database' | ||
export * from './token' | ||
export * from './revert' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ReactiveDBException } from './Exception' | ||
|
||
export const tokenMustBeSymbol = (token: any) => | ||
new ReactiveDBException(`Symbol type expected, but got ${ typeof token }: ${ token }`) | ||
|
||
export const clauseMissingError = () => | ||
new ReactiveDBException('Clause must be specified when when reverControoler is passed to delete method') | ||
|
||
export const revertBeforeOperationSuccessError = () => | ||
new ReactiveDBException('You can only revert after the operation that you passed RevertController success') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { mergeTransactionResult } from './merge-transaction-result' | ||
import { ExecutorResult } from '../../interface' | ||
import { warn } from '../../utils' | ||
|
||
export function executor(db: lf.Database, queries: lf.query.Builder[]): Promise<ExecutorResult> { | ||
const tx = db.createTransaction() | ||
|
||
return tx.exec(queries) | ||
.then(ret => ({ | ||
result: true, | ||
...mergeTransactionResult(queries, ret) | ||
})) | ||
.catch((e: Error) => { | ||
warn(`Execute failed, transaction is already marked for rollback.`) | ||
throw e | ||
}) | ||
} |
Oops, something went wrong.