タグ付けされた質問 「typeorm」

4
NESTJSのTypeORMエンティティ-モジュールの外部ではimportステートメントを使用できません
「nest new」コマンドで新しいプロジェクトを開始しました。エンティティファイルを追加するまで問題なく動作します。 次のエラーが発生しました: 'typeorm'から{Entity、Column、PrimaryGeneratedColumn}をインポートします。 ^^^^^^ SyntaxError:モジュールの外部ではimportステートメントを使用できません 私は何を見逃していますか? エンティティをモジュールに追加: import { Module } from '@nestjs/common'; import { BooksController } from './books.controller'; import { BooksService } from './books.service'; import { BookEntity } from './book.entity'; import { TypeOrmModule } from '@nestjs/typeorm'; @Module({ imports: [TypeOrmModule.forFeature([BookEntity])], controllers: [BooksController], providers: [BooksService], }) export class BooksModule {} …
11 nestjs  typeorm 

2
NestJS nodejsは、関係のある1つのクエリでネストされたコメントをロードしますか?
次のモデルがあります。 User、Customer、Comment ユーザーはにコメントできCustomer、ユーザーは別のユーザーのコメントに再帰的に無制限に返信できます。 私はこれを実行しましたが、返信は1つだけに制限されており、すべての返信をネストします。 public async getCommentsForCustomerId(customerId: string): Promise<CustomerComment[]> { return this.find({where: {customer: {id: customerId}, parentComment: null}, relations: ['childComments']}); } ただし、取得した応答は1つのレベルでのみネストされます。 [ { "id": "7b5b654a-efb0-4afa-82ee-c00c38725072", "content": "test", "created_at": "2019-12-03T15:14:48.000Z", "updated_at": "2019-12-03T15:14:49.000Z", "childComments": [ { "id": "7b5b654a-efb0-4afa-82ee-c00c38725073", "content": "test reply", "created_at": "2019-12-03T15:14:48.000Z", "updated_at": "2019-12-03T15:14:49.000Z", "parentCommentId": "7b5b654a-efb0-4afa-82ee-c00c38725072" } ] } ] それらをすべてtypeormでネストするクエリを作成するにはどうすればよいですか? …
10 node.js  typeorm 

1
クエリビルダー内で関数を呼び出す
座標を保持する位置エンティティがあります。半径に基づいて、範囲内にあるすべての場所を取得します。 2つの場所の間の距離を計算する関数(データベースではなくバックエンドコード/ Nestjsロジック)を作成しました。計算された距離が半径以下の場合、この場所を選択します。 この距離計算関数を使用した私の現在のリポジトリ実装: // ... import { distanceFromCoordinatesInKilometers } from '../shared/calculations/distanceFromCoordinatesInKilometers'; @EntityRepository(Location) export class LocationsRepository extends Repository<Location> { public getLocations({ /* ... */ latitude, longitude, radiusInKilometers }: GetLocationsDTO): Promise<Location[]> { const query: SelectQueryBuilder<Location> = this.createQueryBuilder('location'); // .... if(latitude && longitude && radiusInKilometers) { query.andWhere("distanceFromCoordinatesInKilometers(location.latitude, location.longitude, :latitude, :longitude) <= :radiusInKilometers", …
8 typeorm 
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.