Skip to content

Commit

Permalink
fix: no more Saved
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jan 21, 2024
1 parent d8dc9c2 commit 227bca4
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 131 deletions.
5 changes: 2 additions & 3 deletions src/commondao/common.dao.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
CommonLogger,
ErrorMode,
Promisable,
Saved,
ZodError,
ZodSchema,
} from '@naturalcycles/js-lib'
Expand Down Expand Up @@ -76,7 +75,7 @@ export interface CommonDaoHooks<BM extends BaseDBEntity, DBM extends BaseDBEntit
*
* You can do validations as needed here and throw errors, they will be propagated.
*/
afterLoad?: (dbm: Saved<DBM>) => Promisable<Saved<DBM> | null>
afterLoad?: (dbm: DBM) => Promisable<DBM | null>

/**
* Allows to access the DBM just before it's supposed to be saved to the DB.
Expand All @@ -91,7 +90,7 @@ export interface CommonDaoHooks<BM extends BaseDBEntity, DBM extends BaseDBEntit
*
* You can do validations as needed here and throw errors, they will be propagated.
*/
beforeSave?: (dbm: Saved<DBM>) => Promisable<Saved<DBM> | null>
beforeSave?: (dbm: DBM) => Promisable<DBM | null>

/**
* Called in:
Expand Down
12 changes: 10 additions & 2 deletions src/commondao/common.dao.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { mockTime, MOCK_TS_2018_06_21 } from '@naturalcycles/dev-lib/dist/testing'
import { ErrorMode, _omit, _range, _sortBy, pTry, pExpectedError } from '@naturalcycles/js-lib'
import {
ErrorMode,
_omit,
_range,
_sortBy,
pTry,
pExpectedError,
BaseDBEntity,
} from '@naturalcycles/js-lib'
import {
AjvSchema,
AjvValidationError,
Expand Down Expand Up @@ -400,7 +408,7 @@ test('ajvSchema', async () => {
console.log((err as any).data)
})

interface Item {
interface Item extends BaseDBEntity {
id: string
obj: any
}
Expand Down
Loading

0 comments on commit 227bca4

Please sign in to comment.