-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add created at field to record entity
- Loading branch information
Chenqin Nee
authored and
Chenqin Nee
committed
Dec 15, 2022
1 parent
1a7ae9f
commit 92d05c6
Showing
12 changed files
with
69 additions
and
6 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
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
30 changes: 30 additions & 0 deletions
30
packages/core/record/specifications/record-created-at.specification.ts
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,30 @@ | ||
import type { DateVO } from '@egodb/domain' | ||
import { CompositeSpecification } from '@egodb/domain' | ||
import type { Result } from 'oxide.ts' | ||
import { Ok } from 'oxide.ts' | ||
import type { Record } from '../record' | ||
import type { IRecordVisitor } from './interface' | ||
|
||
export class WithRecordCreatedAt extends CompositeSpecification<Record, IRecordVisitor> { | ||
constructor(public readonly date: DateVO) { | ||
super() | ||
} | ||
|
||
isSatisfiedBy(t: Record): boolean { | ||
return this.date.equals(t.createdAt) | ||
} | ||
|
||
/** | ||
* created at should not mutate exisiting record | ||
* @param r - record | ||
* @returns | ||
*/ | ||
mutate(r: Record): Result<Record, string> { | ||
return Ok(r) | ||
} | ||
|
||
accept(v: IRecordVisitor): Result<void, string> { | ||
v.createdAt(this) | ||
return Ok(undefined) | ||
} | ||
} |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.