igdb-typeorm-entities
v1.0.1
Published
TypeORM entity definitions for the IGDB (Internet Game Database) API. Provides ready-to-use entities, enums, and a NestJS module for storing IGDB data in a relational database.
Maintainers
Readme
igdb-typeorm-entities
TypeORM entity definitions for the IGDB (Internet Game Database) API. Provides 73 entities, 23 enums, and an optional NestJS module for storing IGDB data in a relational database.
Installation
npm install igdb-typeorm-entitiesPeer Dependencies
This package requires the following peer dependencies:
| Package | Required |
|---------|----------|
| typeorm >= 0.3.0 | Yes |
| @nestjs/common >= 9.0.0 | Only if using IgdbModule |
| @nestjs/typeorm >= 9.0.0 | Only if using IgdbModule |
Usage
With NestJS
Import the IgdbModule into your application module. It registers all IGDB entities with TypeORM automatically.
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { IgdbModule } from "igdb-typeorm-entities";
@Module({
imports: [
TypeOrmModule.forRoot({
type: "postgres",
// ...your database config
}),
IgdbModule,
],
})
export class AppModule {}Then inject repositories as usual:
import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Game } from "igdb-typeorm-entities";
@Injectable()
export class GameService {
constructor(
@InjectRepository(Game)
private readonly gameRepository: Repository<Game>,
) {}
findAll() {
return this.gameRepository.find({ relations: ["genres", "platforms"] });
}
}Without NestJS
Use the entities directly with a TypeORM data source:
import { DataSource } from "typeorm";
import { Game, Genre, Platform } from "igdb-typeorm-entities";
const dataSource = new DataSource({
type: "postgres",
// ...your database config
entities: [Game, Genre, Platform], // add the entities you need
});Enums
Enums are provided for fields with fixed value sets:
import { GameStatusEnum, GameCategoryEnum } from "igdb-typeorm-entities";
if (game.status === GameStatusEnum.Released) {
// ...
}Entities
Covers the full IGDB API schema:
| Category | Entities |
|----------|----------|
| Games | Game, GameVersion, GameEngine, GameMode, GameVideo, GameStatus, GameType, GameLocalization, GameReleaseFormat, GameTimeToBeat, GameVersionFeature, GameVersionFeatureValue |
| Platforms | Platform, PlatformVersion, PlatformFamily, PlatformLogo, PlatformType, PlatformWebsite, PlatformVersionCompany, PlatformVersionReleaseDate |
| Companies | Company, CompanyLogo, CompanyStatus, CompanyWebsite, InvolvedCompany |
| Media | Cover, Artwork, ArtworkType, Screenshot, GameEngineLogo |
| Characters | Character, CharacterGender, CharacterSpecie, CharacterMugShot |
| Releases | ReleaseDate, ReleaseDateStatus, ReleaseDateRegion, Region, DateFormat |
| Classification | Genre, Keyword, Theme, PlayerPerspective, Franchise |
| Collections | Collection, CollectionType, CollectionMembership, CollectionMembershipType, CollectionRelation, CollectionRelationType |
| Age Ratings | AgeRating, AgeRatingCategory, AgeRatingOrganization, AgeRatingContentDescription, AgeRatingContentDescriptionType, AgeRatingContentDescriptionV2 |
| Languages | Language, LanguageSupport, LanguageSupportType |
| External | ExternalGame, ExternalGameSource, Website, WebsiteType |
| Events | Event, EventLogo, EventNetwork, NetworkType |
| Popularity | PopularityPrimitive, PopularityType |
| Other | AlternativeName, MultiplayerMode, Search |
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
