8 lines
56 KiB
Plaintext
8 lines
56 KiB
Plaintext
|
{
|
||
|
"version": 3,
|
||
|
"sources": ["../../../src/dialects/abstract/query-interface.js"],
|
||
|
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\n\nconst Utils = require('../../utils');\nconst DataTypes = require('../../data-types');\nconst Transaction = require('../../transaction');\nconst QueryTypes = require('../../query-types');\n\n/**\n * The interface that Sequelize uses to talk to all databases\n */\nclass QueryInterface {\n constructor(sequelize, queryGenerator) {\n this.sequelize = sequelize;\n this.queryGenerator = queryGenerator;\n }\n\n /**\n * Create a database\n *\n * @param {string} database Database name to create\n * @param {object} [options] Query options\n * @param {string} [options.charset] Database default character set, MYSQL only\n * @param {string} [options.collate] Database default collation\n * @param {string} [options.encoding] Database default character set, PostgreSQL only\n * @param {string} [options.ctype] Database character classification, PostgreSQL only\n * @param {string} [options.template] The name of the template from which to create the new database, PostgreSQL only\n *\n * @returns {Promise}\n */\n async createDatabase(database, options) {\n options = options || {};\n const sql = this.queryGenerator.createDatabaseQuery(database, options);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Drop a database\n *\n * @param {string} database Database name to drop\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async dropDatabase(database, options) {\n options = options || {};\n const sql = this.queryGenerator.dropDatabaseQuery(database);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Create a schema\n *\n * @param {string} schema Schema name to create\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async createSchema(schema, options) {\n options = options || {};\n const sql = this.queryGenerator.createSchema(schema);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Drop a schema\n *\n * @param {string} schema Schema name to drop\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async dropSchema(schema, options) {\n options = options || {};\n const sql = this.queryGenerator.dropSchema(schema);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Drop all schemas\n *\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async dropAllSchemas(options) {\n options = options || {};\n\n if (!this.queryGenerator._dialect.supports.schemas) {\n return this.sequelize.drop(options);\n }\n const schemas = await this.showAllSchemas(options);\n return Promise.all(schemas.map(schemaName => this.dropSchema(schemaName, options)));\n }\n\n /**\n * Show all schemas\n *\n * @param {object} [options] Query options\n *\n * @returns {Promise<Array>}\n */\n async showAllSchemas(options) {\n options = {\n ...options,\n raw: true,\n type: this.sequelize.QueryTypes.SELECT\n };\n\n const showSchemasSql = this.queryGenerator.showSchemasQuery(options);\n\n const schemaNames = await this.sequelize.query(showSchemasSql, options);\n\n return _.flatten(schemaNames.map(value => value.schema_name ? value.schema_name : value));\n }\n\n /**\n * Return database version\n *\n * @param {object} [options] Query options\n * @param {QueryType} [options.type] Query type\n *\n * @returns {Promise}\n * @private\n */\n async databaseVersion(options) {\n return await this.sequelize.query(\n this.queryGenerator.versionQuery(),\n { ...options, type: QueryTypes.VERSION }\n );\n }\n\n /**\n * Create a table with given set of attributes\n *\n * ```js\n * queryInterface.createTable(\n * 'nameOfTheNewTable',\n * {\n * id: {\n * type: Sequelize.INTEGER,\n * primaryKey: true,\n * autoIncrement: true\n * },\n * createdAt: {\n * ty
|
||
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,QAAQ;AAElB,MAAM,QAAQ,QAAQ;AACtB,MAAM,YAAY,QAAQ;AAC1B,MAAM,cAAc,QAAQ;AAC5B,MAAM,aAAa,QAAQ;AAK3B,qBAAqB;AAAA,EACnB,YAAY,WAAW,gBAAgB;AACrC,SAAK,YAAY;AACjB,SAAK,iBAAiB;AAAA;AAAA,QAgBlB,eAAe,UAAU,SAAS;AACtC,cAAU,WAAW;AACrB,UAAM,MAAM,KAAK,eAAe,oBAAoB,UAAU;AAC9D,WAAO,MAAM,KAAK,UAAU,MAAM,KAAK;AAAA;AAAA,QAWnC,aAAa,UAAU,SAAS;AACpC,cAAU,WAAW;AACrB,UAAM,MAAM,KAAK,eAAe,kBAAkB;AAClD,WAAO,MAAM,KAAK,U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