@d34d/w-orm - v0.6.0
    Preparing search index...

    Function init

    • Starts a new global database connection. Three scenarios are possible:

      1. There's already a connection, we reuse it
      2. There's no version bump, a new connection is created
      3. There's a version bump, a new connection is created, migrations are applied and tables created

      Parameters

      • dbName: string

        The database name

      • version: number

        The database version, a version bump will trigger an upgrade

      • Optionalmigrations: MigrationList

        A list of migrations to be applied

      Returns Promise<InitResponse>

      • The database connection and whether an upgrade was performed

      Types.MigrationList: For more information on migrations

      const initResp = await init('my-db', 1)
      if (initResp.upgraded) {
      console.log("Database was upgraded")
      }