How to use the @keystonejs/utils.versionGreaterOrEqualTo function in @keystonejs/utils

To help you get started, we’ve selected a few @keystonejs/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keystonejs / keystone / packages / adapter-knex / lib / adapter-knex.js View on Github external
async checkDatabaseVersion() {
    let version;
    try {
      // Using `raw` due to knex not having the SHOW command
      const result = await this.knex.raw('SHOW server_version;');
      // the version is inside the first row "server_version"
      version = result.rows[0].server_version;
    } catch (error) {
      throw new Error(`Error reading version from PostgreSQL: ${error}`);
    }

    if (!versionGreaterOrEqualTo(version, this.minVer)) {
      throw new Error(
        `PostgreSQL version ${version} is incompatible. Version ${this.minVer} or later is required.`
      );
    }
  }
}
github keystonejs / keystone / packages / adapter-mongoose / lib / adapter-mongoose.js View on Github external
async checkDatabaseVersion() {
    let info;

    try {
      info = await new this.mongoose.mongo.Admin(this.mongoose.connection.db).buildInfo();
    } catch (error) {
      console.log(`Error reading version from MongoDB: ${error}`);
    }

    if (!versionGreaterOrEqualTo(info.versionArray, this.minVer)) {
      throw new Error(
        `MongoDB version ${info.version} is incompatible. Version ${this.minVer} or later is required.`
      );
    }
  }
}