Skip to main content
Version: 5.9

MongoSchemaGenerator

Hierarchy

  • AbstractSchemaGenerator<MongoDriver>
    • MongoSchemaGenerator

Index

Constructors

constructor

  • new MongoSchemaGenerator(em: EntityManager<IDatabaseDriver<Connection>> | MongoDriver): MongoSchemaGenerator
  • Parameters

    • em: EntityManager<IDatabaseDriver<Connection>> | MongoDriver

    Returns MongoSchemaGenerator

Methods

clearDatabase

  • clearDatabase(options?: { schema?: string }): Promise<void>
  • Parameters

    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns Promise<void>

createDatabase

  • createDatabase(name: string): Promise<void>
  • creates new database and connects to it


    Parameters

    • name: string

    Returns Promise<void>

createSchema

  • createSchema(options?: CreateSchemaOptions): Promise<void>
  • Parameters

    • options: CreateSchemaOptions = {}

    Returns Promise<void>

dropDatabase

  • dropDatabase(name?: string): Promise<void>
  • Parameters

    • optionalname: string

    Returns Promise<void>

dropIndexes

  • dropIndexes(options?: { collectionsWithFailedIndexes?: string[]; skipIndexes?: { collection: string; indexName: string }[] }): Promise<void>
  • Parameters

    • optionaloptions: { collectionsWithFailedIndexes?: string[]; skipIndexes?: { collection: string; indexName: string }[] }
      • optionalcollectionsWithFailedIndexes: string[]
      • optionalskipIndexes: { collection: string; indexName: string }[]

    Returns Promise<void>

dropSchema

  • dropSchema(options?: { dropMigrationsTable?: boolean }): Promise<void>
  • Parameters

    • options: { dropMigrationsTable?: boolean } = {}
      • optionaldropMigrationsTable: boolean

    Returns Promise<void>

ensureDatabase

  • ensureDatabase(): Promise<boolean>
  • Returns true if the database was created.


    Returns Promise<boolean>

ensureIndexes

  • ensureIndexes(options?: EnsureIndexesOptions): Promise<void>
  • Parameters

    • options: EnsureIndexesOptions = {}

    Returns Promise<void>

execute

  • execute(query: string): Promise<void>
  • Parameters

    • query: string

    Returns Promise<void>

generate

  • generate(): Promise<string>
  • @deprecated

    use dropSchema and createSchema commands respectively


    Returns Promise<string>

getCreateSchemaSQL

  • getCreateSchemaSQL(): Promise<string>
  • Returns Promise<string>

getDropSchemaSQL

  • getDropSchemaSQL(): Promise<string>
  • Returns Promise<string>

getUpdateSchemaMigrationSQL

  • getUpdateSchemaMigrationSQL(): Promise<{ down: string; up: string }>
  • Returns Promise<{ down: string; up: string }>

getUpdateSchemaSQL

  • getUpdateSchemaSQL(): Promise<string>
  • Returns Promise<string>

refreshDatabase

  • refreshDatabase(options?: CreateSchemaOptions): Promise<void>
  • Parameters

    • options: CreateSchemaOptions = {}

    Returns Promise<void>

updateSchema

  • updateSchema(options?: CreateSchemaOptions): Promise<void>
  • Parameters

    • options: CreateSchemaOptions = {}

    Returns Promise<void>

staticregister

  • register(orm: MikroORM<IDatabaseDriver<Connection>>): void
  • Parameters

    • orm: MikroORM<IDatabaseDriver<Connection>>

    Returns void