Skip to content

Commit

Permalink
fix: simplify query
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-scheers-lemon committed Oct 24, 2024
1 parent a76305e commit 4deb437
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions packages/framework-integration-tests/src/queries/search-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,22 @@ import { QueryInfo } from '@boostercloud/framework-types'
import { BookReadModel } from '../read-models/book-read-model'
import { MovieReadModel } from '../read-models/movie-read-model'

export abstract class BaseQuery<M extends BaseQuery<M>> {
constructor(obj: M) {
Object.assign(this, obj)
}
}

export class BookMedia extends BaseQuery<BookMedia> {
export class BookMedia {
title!: string
pages!: number
constructor(book: BookMedia) {
;(this.title = book.title), (this.pages = book.pages)
}
}

export class MovieMedia extends BaseQuery<MovieMedia> {
export class MovieMedia {
title!: string
}

export class Media extends BaseQuery<Media> {
mediaType!: MediaType
constructor(movie: MovieMedia) {
this.title = movie.title
}
}

export type MediaValue = BookMedia | MovieMedia

export enum MediaType {
BookMedia = 'BookMedia',
MovieMedia = 'MovieMedia',
}

class SearchResult {
readonly results!: MediaValue[]
constructor(results: MediaValue[]) {
Expand Down

0 comments on commit 4deb437

Please sign in to comment.