CINXE.COM
<!DOCTYPE html><html><head> <meta charset="utf-8"> <base data-ice="baseUrl" href="../../"> <title data-ice="title">Sequelize | Sequelize</title> <link type="text/css" rel="stylesheet" href="css/style.css"> <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css"> <script src="script/prettify/prettify.js"></script> <script src="script/manual.js"></script> <link rel="stylesheet" href="./inject/css/0-style.css"><link rel="stylesheet" href="./inject/css/0-theme.css"><meta name="description" content="An easy-to-use multi SQL dialect ORM for Node.js"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="Sequelize"><meta property="twitter:description" content="An easy-to-use multi SQL dialect ORM for Node.js"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head> <body class="layout-container" data-ice="rootContainer"> <header> <a href="./" style="display: flex; align-items: center;"><img src="./image/brand_logo.png" style="width:34px;"></a> <a href="/docs/v6/intro/" data-ice="manualHeaderLink" class="api-reference-link">Guides</a> <a href="identifiers.html">Reference</a> <a href="source.html">Source</a> <div class="search-box"> <span> <img src="./image/search.png"> <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span> </span> <ul class="search-result"></ul> </div> <a style="position:relative; top:3px;" href="https://github.com/sequelize/sequelize"><img width="30px" src="./image/github.png" style="width: 30px;"></a></header> <nav class="navigation" data-ice="nav"><button id="navigationHamburger" class="hamburger" type="button"><span class="line"></span><span class="line"></span><span class="line"></span></button><div> <ul> <li data-ice="doc" style="margin-top: 15px;"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/model.js~Model.html">Model</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html">Sequelize</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/transaction.js~Transaction.html">Transaction</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-format">format</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-formatNamedParameters">formatNamedParameters</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-safeStringifyJson">safeStringifyJson</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-DataTypes">DataTypes</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-Deferrable">Deferrable</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-IndexHints">IndexHints</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-QueryTypes">QueryTypes</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-TableHints">TableHints</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#associations">associations</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/associations/base.js~Association.html">Association</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/associations/belongs-to-many.js~BelongsToMany.html">BelongsToMany</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/associations/belongs-to.js~BelongsTo.html">BelongsTo</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/associations/has-many.js~HasMany.html">HasMany</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/associations/has-one.js~HasOne.html">HasOne</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-abstract">dialects/abstract</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/abstract/query-interface.js~QueryInterface.html">QueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-db2">dialects/db2</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/db2/query-interface.js~Db2QueryInterface.html">Db2QueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-mssql">dialects/mssql</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/mssql/async-queue.ts~AsyncQueueError.html">AsyncQueueError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/mssql/query-interface.js~MSSqlQueryInterface.html">MSSqlQueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-mysql">dialects/mysql</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/mysql/query-interface.js~MySQLQueryInterface.html">MySQLQueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-oracle">dialects/oracle</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/oracle/query-interface.js~OracleQueryInterface.html">OracleQueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-postgres">dialects/postgres</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/postgres/query-interface.js~PostgresQueryInterface.html">PostgresQueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-snowflake">dialects/snowflake</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/snowflake/query-interface.js~SnowflakeQueryInterface.html">SnowflakeQueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#dialects-sqlite">dialects/sqlite</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/dialects/sqlite/query-interface.js~SQLiteQueryInterface.html">SQLiteQueryInterface</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#errors">errors</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/aggregate-error.ts~AggregateError.html">AggregateError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/association-error.ts~AssociationError.html">AssociationError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/base-error.ts~BaseError.html">BaseError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/bulk-record-error.ts~BulkRecordError.html">BulkRecordError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection-error.ts~ConnectionError.html">ConnectionError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/database-error.ts~DatabaseError.html">DatabaseError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/eager-loading-error.ts~EagerLoadingError.html">EagerLoadingError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/empty-result-error.ts~EmptyResultError.html">EmptyResultError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/instance-error.ts~InstanceError.html">InstanceError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/optimistic-lock-error.ts~OptimisticLockError.html">OptimisticLockError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/query-error.ts~QueryError.html">QueryError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/sequelize-scope-error.ts~SequelizeScopeError.html">SequelizeScopeError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/validation-error.ts~ValidationError.html">ValidationError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/validation-error.ts~ValidationErrorItem.html">ValidationErrorItem</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-ValidationErrorItemOrigin">ValidationErrorItemOrigin</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-ValidationErrorItemType">ValidationErrorItemType</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#errors-connection">errors/connection</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/access-denied-error.ts~AccessDeniedError.html">AccessDeniedError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/connection-acquire-timeout-error.ts~ConnectionAcquireTimeoutError.html">ConnectionAcquireTimeoutError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/connection-refused-error.ts~ConnectionRefusedError.html">ConnectionRefusedError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/connection-timed-out-error.ts~ConnectionTimedOutError.html">ConnectionTimedOutError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/host-not-found-error.ts~HostNotFoundError.html">HostNotFoundError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/host-not-reachable-error.ts~HostNotReachableError.html">HostNotReachableError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/connection/invalid-connection-error.ts~InvalidConnectionError.html">InvalidConnectionError</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#errors-database">errors/database</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/database/exclusion-constraint-error.ts~ExclusionConstraintError.html">ExclusionConstraintError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/database/foreign-key-constraint-error.ts~ForeignKeyConstraintError.html">ForeignKeyConstraintError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/database/timeout-error.ts~TimeoutError.html">TimeoutError</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/database/unknown-constraint-error.ts~UnknownConstraintError.html">UnknownConstraintError</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#errors-validation">errors/validation</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/validation/unique-constraint-error.ts~UniqueConstraintError.html">UniqueConstraintError</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-injectReplacements">injectReplacements</a></span></span></li> <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="variable/index.html#static-variable-DataTypes">datatypes</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~ARRAY.html">ARRAY</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~VIRTUAL.html">VIRTUAL</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~UUIDV4.html">UUIDV4</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~UUIDV1.html">UUIDV1</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~UUID.html">UUID</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~TSVECTOR.html">TSVECTOR</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~TINYINT.html">TINYINT</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~TIME.html">TIME</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~TEXT.html">TEXT</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~STRING.html">STRING</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~SMALLINT.html">SMALLINT</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~REAL.html">REAL</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~RANGE.html">RANGE</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~NUMBER.html">NUMBER</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~NOW.html">NOW</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~MEDIUMINT.html">MEDIUMINT</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~MACADDR.html">MACADDR</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~JSONTYPE.html">JSONTYPE</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~JSONB.html">JSONB</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~INTEGER.html">INTEGER</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~INET.html">INET</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~HSTORE.html">HSTORE</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~GEOMETRY.html">GEOMETRY</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~GEOGRAPHY.html">GEOGRAPHY</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~FLOAT.html">FLOAT</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~ENUM.html">ENUM</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~DOUBLE.html">DOUBLE</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~DECIMAL.html">DECIMAL</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~DATEONLY.html">DATEONLY</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~DATE.html">DATE</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~CITEXT.html">CITEXT</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~CIDR.html">CIDR</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~CHAR.html">CHAR</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~BOOLEAN.html">BOOLEAN</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~BLOB.html">BLOB</a></span></span></li><li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/data-types.js~BIGINT.html">BIGINT</a></span></span></li></ul> </div> </nav> <div class="content" data-ice="content"><div class="header-notice"> <div data-ice="importPath" class="import-path"><pre class="prettyprint"><code data-ice="importPathCode"></code></pre></div> <span data-ice="access">public</span> <span data-ice="kind">class</span> <span data-ice="source">| <span><a href="file/src/sequelize.js.html#lineNumber35">source</a></span></span> </div> <div class="self-detail detail"> <h1 data-ice="name">Sequelize</h1> <div class="description" data-ice="description"><p>This is the main class, the entry point to sequelize.</p> </div> </div> <div data-ice="staticMethodSummary"><h2>Static Method Summary</h2><table class="summary" data-ice="summary"> <thead><tr><td data-ice="title" colspan="3">Static Public Methods</td></tr></thead> <tbody> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-and">and</a></span></span><span class="code" data-ice="signature">(args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-and">and</a></span></span> </p> </div> <div> <div data-ice="description"><p>An AND query</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-cast">cast</a></span></span><span class="code" data-ice="signature">(val: <span>any</span>, type: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-cast">cast</a></span></span> </p> </div> <div> <div data-ice="description"><p>Creates an object representing a call to the cast function.</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-col">col</a></span></span><span class="code" data-ice="signature">(col: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-col">col</a></span></span> </p> </div> <div> <div data-ice="description"><p>Creates an object which represents a column in the DB, this allows referencing another column in your query.</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></span><span class="code" data-ice="signature">(fn: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, args: <span>any</span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></span> </p> </div> <div> <div data-ice="description"><p>Creates an object representing a database function.</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-json">json</a></span></span><span class="code" data-ice="signature">(conditionsOrPath: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, value: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-json">json</a></span></span> </p> </div> <div> <div data-ice="description"><p>Creates an object representing nested where conditions for postgres/sqlite/mysql json data-type.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-literal">literal</a></span></span><span class="code" data-ice="signature">(val: <span>any</span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-literal">literal</a></span></span> </p> </div> <div> <div data-ice="description"><p>Creates an object representing a literal, i.e.</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-or">or</a></span></span><span class="code" data-ice="signature">(args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-or">or</a></span></span> </p> </div> <div> <div data-ice="description"><p>An OR query</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-useCLS">useCLS</a></span></span><span class="code" data-ice="signature">(ns: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></span> </p> </div> <div> <div data-ice="description"><p>Use CLS (Continuation Local Storage) with Sequelize.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-where">where</a></span></span><span class="code" data-ice="signature">(attr: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, comparator: <span>symbol</span>, logic: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span>*</span></span> </p> </div> <div> <div data-ice="description"><p>A way of specifying attr = condition.</p> </div> </div> </td> <td> <span class="since" data-ice="since">since v2.0.0-dev3</span> </td> </tr> </tbody> </table> </div> <div data-ice="constructorSummary"><h2>Constructor Summary</h2><table class="summary" data-ice="summary"> <thead><tr><td data-ice="title" colspan="3">Public Constructor</td></tr></thead> <tbody> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-constructor-constructor">constructor</a></span></span><span class="code" data-ice="signature">(database: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, username: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, password: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>)</span> </p> </div> <div> <div data-ice="description"><p>Instantiate sequelize with name of database, username and password.</p> </div> </div> </td> <td> </td> </tr> </tbody> </table> </div> <div data-ice="memberSummary"><h2>Member Summary</h2><table class="summary" data-ice="summary"> <thead><tr><td data-ice="title" colspan="3">Public Members</td></tr></thead> <tbody> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-member-models">models</a></span></span><span class="code" data-ice="signature">: {}</span> </p> </div> <div> <div data-ice="description"><p>Models are stored here under the name given to <code>sequelize.define</code></p> </div> </div> </td> <td> </td> </tr> </tbody> </table> </div> <div data-ice="methodSummary"><h2>Method Summary</h2><table class="summary" data-ice="summary"> <thead><tr><td data-ice="title" colspan="3">Public Methods</td></tr></thead> <tbody> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-authenticate">authenticate</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Test the connection by trying to authenticate.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-close">close</a></span></span><span class="code" data-ice="signature">(): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Close all connections used by this sequelize instance, and free all references so the instance can be garbage collected.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-createSchema">createSchema</a></span></span><span class="code" data-ice="signature">(schema: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Create a new database schema.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-define">define</a></span></span><span class="code" data-ice="signature">(modelName: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, attributes: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="class/src/model.js~Model.html">Model</a></span></span> </p> </div> <div> <div data-ice="description"><p>Define a new model, representing a table in the database.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-drop">drop</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Drop all tables defined through this sequelize instance.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-dropAllSchemas">dropAllSchemas</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Drop all schemas.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-dropSchema">dropSchema</a></span></span><span class="code" data-ice="signature">(schema: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Drop a single schema</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-escape">escape</a></span></span><span class="code" data-ice="signature">(value: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></span> </p> </div> <div> <div data-ice="description"><p>Escape value.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-getDatabaseName">getDatabaseName</a></span></span><span class="code" data-ice="signature">(): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></span> </p> </div> <div> <div data-ice="description"><p>Returns the database name.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-getDialect">getDialect</a></span></span><span class="code" data-ice="signature">(): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></span> </p> </div> <div> <div data-ice="description"><p>Returns the specified dialect.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-getQueryInterface">getQueryInterface</a></span></span><span class="code" data-ice="signature">(): <span><a href="class/src/dialects/abstract/query-interface.js~QueryInterface.html">QueryInterface</a></span></span> </p> </div> <div> <div data-ice="description"><p>Returns an instance of QueryInterface.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-isDefined">isDefined</a></span></span><span class="code" data-ice="signature">(modelName: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></span> </p> </div> <div> <div data-ice="description"><p>Checks whether a model with the given name is defined</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-model">model</a></span></span><span class="code" data-ice="signature">(modelName: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="class/src/model.js~Model.html">Model</a></span></span> </p> </div> <div> <div data-ice="description"><p>Fetch a Model which is already defined</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-query">query</a></span></span><span class="code" data-ice="signature">(sql: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Execute a query on the DB, optionally bypassing all the Sequelize goodness.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-random">random</a></span></span><span class="code" data-ice="signature">(): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></span> </p> </div> <div> <div data-ice="description"><p>Get the fn for random based on the dialect</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-set">set</a></span></span><span class="code" data-ice="signature">(variables: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Execute a query which would set an environment or user variable.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-showAllSchemas">showAllSchemas</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Show all defined schemas</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-sync">sync</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Sync all defined models to the DB.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-transaction">transaction</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, autoCallback: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Start a transaction.</p> </div> </div> </td> <td> </td> </tr> <tr data-ice="target"> <td> <span class="access" data-ice="access">public</span> <span class="override" data-ice="override"></span> </td> <td> <div> <p> <span data-ice="async">async</span> <span class="code" data-ice="name"><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-truncate">truncate</a></span></span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> </p> </div> <div> <div data-ice="description"><p>Truncate all tables defined through the sequelize models.</p> </div> </div> </td> <td> </td> </tr> </tbody> </table> </div> <div data-ice="staticMethodDetails"><h2 data-ice="title">Static Public Methods</h2> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-and"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">and</span><span class="code" data-ice="signature">(args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-and">and</a></span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1075">source</a></span></span> </span> </h3> <div data-ice="description"><p>An AND query</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">args</td> <td data-ice="type" class="code">...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>Each argument will be joined by AND</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-and">and</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-findAll">Model.findAll</a></span></span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-cast"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">cast</span><span class="code" data-ice="signature">(val: <span>any</span>, type: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-cast">cast</a></span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1046">source</a></span></span> </span> </h3> <div data-ice="description"><p>Creates an object representing a call to the cast function.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">val</td> <td data-ice="type" class="code"><span>any</span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The value to cast</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">type</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The type to cast it to</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-cast">cast</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-col"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">col</span><span class="code" data-ice="signature">(col: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-col">col</a></span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1032">source</a></span></span> </span> </h3> <div data-ice="description"><p>Creates an object which represents a column in the DB, this allows referencing another column in your query. This is often useful in conjunction with <code>sequelize.fn</code>, since raw string arguments to fn will be escaped.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">col</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The name of the column</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-col">col</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span>Sequelize#fn</span></span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-fn"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">fn</span><span class="code" data-ice="signature">(fn: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, args: <span>any</span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1016">source</a></span></span> </span> </h3> <div data-ice="description"><p>Creates an object representing a database function. This can be used in search queries, both in where and order parts, and as default values in column definitions. If you want to refer to columns in your function, you should use <code>sequelize.col</code>, so that the columns are properly interpreted as columns and not a strings.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">fn</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The function you want to call</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">args</td> <td data-ice="type" class="code"><span>any</span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>All further arguments will be passed as arguments to the function</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="example"> <h4>Example:</h4> <div class="example-doc" data-ice="exampleDoc"> <div class="example-caption" data-ice="exampleCaption">Convert a user's username to upper case</div> <pre class="prettyprint source-code"><code data-ice="exampleCode">instance.update({ username: sequelize.fn('upper', sequelize.col('username')) });</code></pre> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-findAll">Model.findAll</a></span></span></li> <li><span><span><a href="class/src/sequelize.js~Sequelize.html#instance-method-define">Sequelize.define</a></span></span></li> <li><span><span><a href="class/src/sequelize.js~Sequelize.html#static-method-col">Sequelize.col</a></span></span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-json"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">json</span><span class="code" data-ice="signature">(conditionsOrPath: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, value: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-json">json</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1107">source</a></span></span> </span> </h3> <div data-ice="description"><p>Creates an object representing nested where conditions for postgres/sqlite/mysql json data-type.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">conditionsOrPath</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>A hash containing strings/numbers or other nested hash, a string using dot notation or a string using postgres/sqlite/mysql json syntax.</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">value</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>An optional value to compare against. Produces a string of the form "<json path> = '<value>'".</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-json">json</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-findAll">Model.findAll</a></span></span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-literal"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">literal</span><span class="code" data-ice="signature">(val: <span>any</span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-literal">literal</a></span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1059">source</a></span></span> </span> </h3> <div data-ice="description"><p>Creates an object representing a literal, i.e. something that will not be escaped.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">val</td> <td data-ice="type" class="code"><span>any</span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>literal value</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-literal">literal</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-or"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">or</span><span class="code" data-ice="signature">(args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-or">or</a></span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1091">source</a></span></span> </span> </h3> <div data-ice="description"><p>An OR query</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">args</td> <td data-ice="type" class="code">...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>Each argument will be joined by OR</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-or">or</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-findAll">Model.findAll</a></span></span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-useCLS"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">useCLS</span><span class="code" data-ice="signature">(ns: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1223">source</a></span></span> </span> </h3> <div data-ice="description"><p>Use CLS (Continuation Local Storage) with Sequelize. With Continuation Local Storage, all queries within the transaction callback will automatically receive the transaction object.</p> <p>CLS namespace provided is stored as <code>Sequelize._cls</code></p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">ns</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>CLS namespace</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>Sequelize constructor</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="static-method-where"> <span class="access" data-ice="access">public</span> <span data-ice="static">static</span> <span class="code" data-ice="name">where</span><span class="code" data-ice="signature">(attr: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, comparator: <span>symbol</span>, logic: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span>*</span></span> <span class="right-info"> <span class="since" data-ice="since">since v2.0.0-dev3</span> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1127">source</a></span></span> </span> </h3> <div data-ice="description"><p>A way of specifying attr = condition.</p> <p>The attr can either be an object taken from <code>Model.rawAttributes</code> (for example <code>Model.rawAttributes.id</code> or <code>Model.rawAttributes.name</code>). The attribute should be defined in your model definition. The attribute can also be an object from one of the sequelize utility functions (<code>sequelize.fn</code>, <code>sequelize.col</code> etc.)</p> <p>For string attributes, use the regular <code>{ where: { attr: something }}</code> syntax. If you don't want your string to be escaped, use <code>sequelize.literal</code>.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">attr</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The attribute, which can be either an attribute object from <code>Model.rawAttributes</code> or a sequelize object, for example an instance of <code>sequelize.fn</code>. For simple string attributes, use the POJO syntax</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">comparator</td> <td data-ice="type" class="code"><span>symbol</span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'Op.eq'</li></ul></td> <td data-ice="description"><p>operator</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">logic</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The condition. Can be both a simply type, or a further condition (<code>or</code>, <code>and</code>, <code>.literal</code> etc.)</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span>*</span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-findAll">Model.findAll</a></span></span></li></ul></div> </div> </div> <div data-ice="constructorDetails"><h2 data-ice="title">Public Constructors</h2> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-constructor-constructor"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">constructor</span><span class="code" data-ice="signature">(database: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, username: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, password: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>)</span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber185">source</a></span></span> </span> </h3> <div data-ice="description"><p>Instantiate sequelize with name of database, username and password.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">database</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The name of the database</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">username</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>The username which is used to authenticate against the database.</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">password</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>The password which is used to authenticate against the database. Supports SQLCipher encryption for SQLite.</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>An object with options.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.host</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'localhost'</li></ul></td> <td data-ice="description"><p>The host of the relational database.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.port</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The port of the relational database.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.username</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>The username which is used to authenticate against the database.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.password</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>The password which is used to authenticate against the database.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.database</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>The name of the database.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.dialect</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The dialect of the database you are connecting to. One of mysql, postgres, sqlite, db2, mariadb and mssql.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.dialectModule</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>If specified, use this dialect library. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'require("pg.js")' here</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.dialectModulePath</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>If specified, load the dialect library from this path. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify '/path/to/pg.js' here</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.dialectOptions</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>An object of additional options, which are passed directly to the connection library</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.storage</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Only used by sqlite. Defaults to ':memory:'</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.protocol</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'tcp'</li></ul></td> <td data-ice="description"><p>The protocol of the relational database.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.define</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>Default options for model definitions. See <span><a href="class/src/model.js~Model.html#static-method-init">Model.init</a></span>.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.query</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>Default options for sequelize.query</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.schema</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>A schema to use</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.set</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>Default options for sequelize.set</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.sync</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>Default options for sequelize.sync</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.timezone</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: '+00:00'</li></ul></td> <td data-ice="description"><p>The timezone used when converting a date from the database into a JavaScript date. The timezone is also used to SET TIMEZONE when connecting to the server, to ensure that the result of NOW, CURRENT_TIMESTAMP and other time related functions have in the right timezone. For best cross platform performance use the format +/-HH:MM. Will also accept string versions of timezones used by moment.js (e.g. 'America/Los_Angeles'); this is useful to capture daylight savings time changes.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.clientMinMessages</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'warning'</li></ul></td> <td data-ice="description"><p>(Deprecated) The PostgreSQL <code>client_min_messages</code> session parameter. Set to <code>false</code> to not override the database's default.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.standardConformingStrings</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: true</li></ul></td> <td data-ice="description"><p>The PostgreSQL <code>standard_conforming_strings</code> session parameter. Set to <code>false</code> to not set the option. WARNING: Setting this to false may expose vulnerabilities and is not recommended!</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: console.log</li></ul></td> <td data-ice="description"><p>A function that gets executed every time Sequelize would log something. Function may receive multiple parameters but only first one is printed by <code>console.log</code>. To print all values use <code>(...msg) => console.log(msg)</code></p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.benchmark</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Pass query execution time in milliseconds as second argument to logging function (options.logging).</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.omitNull</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>A flag that defines if null values should be passed as values to CREATE/UPDATE SQL queries or not.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.native</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>A flag that defines if native library shall be used or not. Currently only has an effect for postgres</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.ssl</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: undefined</li></ul></td> <td data-ice="description"><p>A flag that defines if connection should be over ssl or not</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.replication</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: <code>host</code>, <code>port</code>, <code>username</code>, <code>password</code>, <code>database</code></p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.pool</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>sequelize connection pool configuration</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.max</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 5</li></ul></td> <td data-ice="description"><p>Maximum number of connection in pool</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.min</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 0</li></ul></td> <td data-ice="description"><p>Minimum number of connection in pool</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.idle</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 10000</li></ul></td> <td data-ice="description"><p>The maximum time, in milliseconds, that a connection can be idle before being released.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.acquire</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 60000</li></ul></td> <td data-ice="description"><p>The maximum time, in milliseconds, that pool will try to get connection before throwing error</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.evict</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 1000</li></ul></td> <td data-ice="description"><p>The time interval, in milliseconds, after which sequelize-pool will remove idle connections.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.validate</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.pool.maxUses</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: Infinity</li></ul></td> <td data-ice="description"><p>The number of times a connection can be used before discarding it for a replacement, <a href="https://github.com/sequelize/sequelize-pool"><code>used for eventual cluster rebalancing</code></a>.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.quoteIdentifiers</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: true</li></ul></td> <td data-ice="description"><p>Set to <code>false</code> to make table names and attributes case-insensitive on Postgres and skip double quoting of them. WARNING: Setting this to false may expose vulnerabilities and is not recommended!</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.transactionType</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'DEFERRED'</li></ul></td> <td data-ice="description"><p>Set the default transaction type. See <code>Sequelize.Transaction.TYPES</code> for possible options. Sqlite only.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.isolationLevel</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Set the default transaction isolation level. See <code>Sequelize.Transaction.ISOLATION_LEVELS</code> for possible options.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.retry</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Set of flags that control when a query is automatically retried. Accepts all options for <a href="https://github.com/mickhansen/retry-as-promised"><code>retry-as-promised</code></a>.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.retry.match</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Only retry a query if the error matches one of these strings.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.retry.max</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>How many times a failing query is automatically retried. Set to 0 to disable retrying on SQL_BUSY error.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.typeValidation</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Run built-in type validators on insert and update, and select with where clause, e.g. validate that arguments passed to integer fields are integer-like.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.operatorsAliases</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>String based operator alias. Pass object to limit set of aliased operators.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.hooks</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>An object of global hook functions that are called before and after certain lifecycle events. Global hooks will run after any model-specific hooks defined for the same event (See <code>Sequelize.Model.init()</code> for a list). Additionally, <code>beforeConnect()</code>, <code>afterConnect()</code>, <code>beforeDisconnect()</code>, and <code>afterDisconnect()</code> hooks may be defined here.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.minifyAliases</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>A flag that defines if aliases should be minified (mostly useful to avoid Postgres alias character limit of 64)</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logQueryParameters</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>A flag that defines if show bind parameters in log.</p> </td> </tr> </tbody> </table> </div> </div> <div data-ice="example"> <h4>Example:</h4> <div class="example-doc" data-ice="exampleDoc"> <pre class="prettyprint source-code"><code data-ice="exampleCode">// without password / with blank password const sequelize = new Sequelize('database', 'username', null, { dialect: 'mysql' }) // with password and options const sequelize = new Sequelize('my_database', 'john', 'doe', { dialect: 'postgres' }) // with database, username, and password in the options object const sequelize = new Sequelize({ database, username, password, dialect: 'mssql' }); // with uri const sequelize = new Sequelize('mysql://localhost:3306/database', {}) // option examples const sequelize = new Sequelize('database', 'username', 'password', { // the sql dialect of the database // currently supported: 'mysql', 'sqlite', 'postgres', 'mssql' dialect: 'mysql', // custom host; default: localhost host: 'my.server.tld', // for postgres, you can also specify an absolute path to a directory // containing a UNIX socket to connect over // host: '/sockets/psql_sockets'. // custom port; default: dialect default port: 12345, // custom protocol; default: 'tcp' // postgres only, useful for Heroku protocol: null, // disable logging or provide a custom logging function; default: console.log logging: false, // you can also pass any dialect options to the underlying dialect library // - default is empty // - currently supported: 'mysql', 'postgres', 'mssql' dialectOptions: { socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock', supportBigNumbers: true, bigNumberStrings: true }, // the storage engine for sqlite // - default ':memory:' storage: 'path/to/database.sqlite', // disable inserting undefined values as NULL // - default: false omitNull: true, // a flag for using a native library or not. // in the case of 'pg' -- set this to true will allow SSL support // - default: false native: true, // A flag that defines if connection should be over ssl or not // - default: undefined ssl: true, // Specify options, which are used when sequelize.define is called. // The following example: // define: { timestamps: false } // is basically the same as: // Model.init(attributes, { timestamps: false }); // sequelize.define(name, attributes, { timestamps: false }); // so defining the timestamps for each model will be not necessary define: { underscored: false, freezeTableName: false, charset: 'utf8', dialectOptions: { collate: 'utf8_general_ci' }, timestamps: true }, // similar for sync: you can define this to always force sync for models sync: { force: true }, // pool configuration used to pool database connections pool: { max: 5, idle: 30000, acquire: 60000, }, // isolation level of each transaction // defaults to dialect default isolationLevel: Transaction.ISOLATION_LEVELS.REPEATABLE_READ })</code></pre> </div> </div> </div> </div> <div data-ice="memberDetails"><h2 data-ice="title">Public Members</h2> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-member-models"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">models</span><span class="code" data-ice="signature">: {}</span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber383">source</a></span></span> </span> </h3> <div data-ice="description"><p>Models are stored here under the name given to <code>sequelize.define</code></p> </div> <div data-ice="properties"> </div> </div> </div> <div data-ice="methodDetails"><h2 data-ice="title">Public Methods</h2> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-authenticate"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">authenticate</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber964">source</a></span></span> </span> </h3> <div data-ice="description"><p>Test the connection by trying to authenticate. It runs <code>SELECT 1+1 AS result</code> query.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>query options</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-close"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">close</span><span class="code" data-ice="signature">(): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1293">source</a></span></span> </span> </h3> <div data-ice="description"><p>Close all connections used by this sequelize instance, and free all references so the instance can be garbage collected.</p> <p>Normally this is done on process exit, so you only need to call this method if you are creating multiple instances, and want to garbage collect some of them.</p> </div> <div data-ice="properties"> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-createSchema"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">createSchema</span><span class="code" data-ice="signature">(schema: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber723">source</a></span></span> </span> </h3> <div data-ice="description"><p>Create a new database schema.</p> <p><strong>Note:</strong> this is a schema in the <a href="http://www.postgresql.org/docs/9.1/static/ddl-schemas.html">postgres sense of the word</a>, not a database table. In mysql and sqlite, this command will do nothing.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">schema</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>Name of the schema</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>query options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-schema">Model.schema</a></span></span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-define"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">define</span><span class="code" data-ice="signature">(modelName: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, attributes: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="class/src/model.js~Model.html">Model</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber462">source</a></span></span> </span> </h3> <div data-ice="description"><p>Define a new model, representing a table in the database.</p> <p>The table columns are defined by the object that is given as the second argument. Each key of the object represents a column</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">modelName</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The name of the model. The model will be stored in <code>sequelize.models</code> under this name</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">attributes</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>An object, where each attribute is a column of the table. See <span><a href="class/src/model.js~Model.html#static-method-init">Model.init</a></span></p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>These options are merged with the default define options provided to the Sequelize constructor and passed to Model.init()</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/model.js~Model.html">Model</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>Newly defined model</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="example"> <h4>Example:</h4> <div class="example-doc" data-ice="exampleDoc"> <pre class="prettyprint source-code"><code data-ice="exampleCode">sequelize.define('modelName', { columnA: { type: Sequelize.BOOLEAN, validate: { is: ["[a-z]",'i'], // will only allow letters max: 23, // only allow values <= 23 isIn: { args: [['en', 'zh']], msg: "Must be English or Chinese" } }, field: 'column_a' }, columnB: Sequelize.STRING, columnC: 'MY VERY OWN COLUMN TYPE' }); sequelize.models.modelName // The model will now be available in models under the name given to define</code></pre> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-init">Model.init</a></span> for a more comprehensive specification of the `options` and `attributes` objects.</span></li> <li><span><a href="/master/manual/model-basics.html">Model Basics</a> guide</span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-drop"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">drop</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber914">source</a></span></span> </span> </h3> <div data-ice="description"><p>Drop all tables defined through this sequelize instance. This is done by calling Model.drop on each model.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The options passed to each call to Model.drop</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-drop">Model.drop</a></span> for options</span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-dropAllSchemas"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">dropAllSchemas</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber769">source</a></span></span> </span> </h3> <div data-ice="description"><p>Drop all schemas.</p> <p><strong>Note:</strong> this is a schema in the <a href="http://www.postgresql.org/docs/9.1/static/ddl-schemas.html">postgres sense of the word</a>, not a database table. In mysql and sqlite, this is the equivalent of drop all tables.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>query options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-dropSchema"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">dropSchema</span><span class="code" data-ice="signature">(schema: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber754">source</a></span></span> </span> </h3> <div data-ice="description"><p>Drop a single schema</p> <p><strong>Note:</strong> this is a schema in the <a href="http://www.postgresql.org/docs/9.1/static/ddl-schemas.html">postgres sense of the word</a>, not a database table. In mysql and sqlite, this drop a table matching the schema name</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">schema</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>Name of the schema</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>query options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-escape"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">escape</span><span class="code" data-ice="signature">(value: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber704">source</a></span></span> </span> </h3> <div data-ice="description"><p>Escape value.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">value</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>string value to escape</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-getDatabaseName"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">getDatabaseName</span><span class="code" data-ice="signature">(): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber413">source</a></span></span> </span> </h3> <div data-ice="description"><p>Returns the database name.</p> </div> <div data-ice="properties"> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>The database name.</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-getDialect"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">getDialect</span><span class="code" data-ice="signature">(): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber404">source</a></span></span> </span> </h3> <div data-ice="description"><p>Returns the specified dialect.</p> </div> <div data-ice="properties"> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>The specified dialect.</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-getQueryInterface"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">getQueryInterface</span><span class="code" data-ice="signature">(): <span><a href="class/src/dialects/abstract/query-interface.js~QueryInterface.html">QueryInterface</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber422">source</a></span></span> </span> </h3> <div data-ice="description"><p>Returns an instance of QueryInterface.</p> </div> <div data-ice="properties"> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/dialects/abstract/query-interface.js~QueryInterface.html">QueryInterface</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>An instance (singleton) of QueryInterface.</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-isDefined"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">isDefined</span><span class="code" data-ice="signature">(modelName: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber496">source</a></span></span> </span> </h3> <div data-ice="description"><p>Checks whether a model with the given name is defined</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">modelName</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The name of a model defined with Sequelize.define</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>Returns true if model is already defined, otherwise false</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-model"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">model</span><span class="code" data-ice="signature">(modelName: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>): <span><a href="class/src/model.js~Model.html">Model</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber481">source</a></span></span> </span> </h3> <div data-ice="description"><p>Fetch a Model which is already defined</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">modelName</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>The name of a model defined with Sequelize.define</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/model.js~Model.html">Model</a></span></td> <td class="return-desc" data-ice="returnDescription"><p>Specified model</p> </td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="throwWrap"> <h4>Throw:</h4> <table> <tbody> <tr class="throw" data-ice="throw"> <td><p data-ice="throwName"><span>*</span></p></td> <td data-ice="throwDesc"><p>Will throw an error if the model is not defined (that is, if sequelize#isDefined returns false)</p> </td> </tr> </tbody> </table> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-query"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">query</span><span class="code" data-ice="signature">(sql: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber540">source</a></span></span> </span> </h3> <div data-ice="description"><p>Execute a query on the DB, optionally bypassing all the Sequelize goodness.</p> <p>By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.</p> <p>If you are running a type of query where you don't need the metadata, for example a <code>SELECT</code> query, you can pass in a query type to make sequelize format the results:</p> <pre><code class="lang-js"><code class="source-code prettyprint">const [results, metadata] = await sequelize.query('SELECT...'); // Raw query - use array destructuring const results = await sequelize.query('SELECT...', { type: sequelize.QueryTypes.SELECT }); // SELECT query - no destructuring</code> </code></pre> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">sql</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"></td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>Query options.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.raw</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>If true, sequelize will not try to format the results of the query, or build an instance of a model from the result</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.transaction</td> <td data-ice="type" class="code"><span><a href="class/src/transaction.js~Transaction.html">Transaction</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: null</li></ul></td> <td data-ice="description"><p>The transaction that the query should be executed under</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.type</td> <td data-ice="type" class="code"><span><a href="variable/index.html#static-variable-QueryTypes">QueryTypes</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'RAW'</li></ul></td> <td data-ice="description"><p>The type of query you are executing. The query type affects how results are formatted before they are passed back. The type is a string, but <code>Sequelize.QueryTypes</code> is provided as convenience shortcuts.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.nest</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>If true, transforms objects with <code>.</code> separated property names into nested objects using <a href="https://github.com/mickhansen/dottie.js">dottie.js</a>. For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When <code>nest</code> is true, the query type is assumed to be <code>'SELECT'</code>, unless otherwise specified</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.plain</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Sets the query type to <code>SELECT</code> and return a single row</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.replacements</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Either an object of named parameter replacements in the format <code>:param</code> or an array of unnamed replacements to replace <code>?</code> in your SQL.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.bind</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Either an object of named bind parameter in the format <code>_param</code> or an array of unnamed bind parameter to replace <code>$1, $2, ...</code> in your SQL.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.useMaster</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Force the query to use the write pool, regardless of the query type.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>A function that gets executed while running the query to log the sql.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.instance</td> <td data-ice="type" class="code"><span><a href="class/src/model.js~Model.html">Model</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A sequelize model instance whose Model is to be used to build the query result</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.model</td> <td data-ice="type" class="code"><span>typeof Model</span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A sequelize model used to build the returned model instances</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.retry</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Set of flags that control when a query is automatically retried. Accepts all options for <a href="https://github.com/mickhansen/retry-as-promised"><code>retry-as-promised</code></a>.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.retry.match</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Only retry a query if the error matches one of these strings.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.retry.max</td> <td data-ice="type" class="code"><span>Integer</span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>How many times a failing query is automatically retried.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.searchPath</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: DEFAULT</li></ul></td> <td data-ice="description"><p>An optional parameter to specify the schema search_path (Postgres only)</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.supportsSearchPath</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>If false do not prepend the query with the search_path (Postgres only)</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.mapToModel</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Map returned fields to model's fields if <code>options.model</code> or <code>options.instance</code> is present. Mapping will occur before building the model instance.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.fieldMap</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Map returned fields to arbitrary names for <code>SELECT</code> query type.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.rawErrors</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Set to <code>true</code> to cause errors coming from the underlying connection/database library to be propagated unmodified and unformatted. Else, the default behavior (=false) is to reinterpret errors as sequelize.errors.BaseError objects.</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-build">Model.build</a></span> for more information about instance option.</span></li></ul></div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-random"> <span class="access" data-ice="access">public</span> <span class="code" data-ice="name">random</span><span class="code" data-ice="signature">(): <span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber986">source</a></span></span> </span> </h3> <div data-ice="description"><p>Get the fn for random based on the dialect</p> </div> <div data-ice="properties"> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="class/src/sequelize.js~Sequelize.html#static-method-fn">fn</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-set"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">set</span><span class="code" data-ice="signature">(variables: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber672">source</a></span></span> </span> </h3> <div data-ice="description"><p>Execute a query which would set an environment or user variable. The variables are set per connection, so this function needs a transaction. Only works for MySQL or MariaDB.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">variables</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"></td> <td data-ice="description"><p>Object with multiple variables.</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>query options.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.transaction</td> <td data-ice="type" class="code"><span><a href="class/src/transaction.js~Transaction.html">Transaction</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The transaction that the query should be executed under</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-showAllSchemas"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">showAllSchemas</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber738">source</a></span></span> </span> </h3> <div data-ice="description"><p>Show all defined schemas</p> <p><strong>Note:</strong> this is a schema in the <a href="http://www.postgresql.org/docs/9.1/static/ddl-schemas.html">postgres sense of the word</a>, not a database table. In mysql and sqlite, this will show all tables.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>query options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-sync"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">sync</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber788">source</a></span></span> </span> </h3> <div data-ice="description"><p>Sync all defined models to the DB.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: {}</li></ul></td> <td data-ice="description"><p>sync options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.force</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>If force is true, each Model will run <code>DROP TABLE IF EXISTS</code>, before it tries to create its own table</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.match</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">RegExp</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Match a regex against the database name before syncing, a safety check for cases where force: true is used in tests but not live code</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: console.log</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.schema</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'public'</li></ul></td> <td data-ice="description"><p>The schema that the tables should be created in. This can be overridden for each table in sequelize.define</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.searchPath</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: DEFAULT</li></ul></td> <td data-ice="description"><p>An optional parameter to specify the schema search_path (Postgres only)</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.hooks</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: true</li></ul></td> <td data-ice="description"><p>If hooks is true then beforeSync, afterSync, beforeBulkSync, afterBulkSync hooks will be called</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.alter</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>Alters tables to fit models. Provide an object for additional configuration. Not recommended for production use. If not further configured deletes data in columns that were removed or had their type changed in the model.</p> </td> </tr> <tr data-ice="property" data-depth="2"> <td data-ice="name" class="code" data-depth="2">options.alter.drop</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: true</li></ul></td> <td data-ice="description"><p>Prevents any drop statements while altering a table when set to <code>false</code></p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-transaction"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">transaction</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>, autoCallback: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber1178">source</a></span></span> </span> </h3> <div data-ice="description"><p>Start a transaction. When using transactions, you should pass the transaction in the options argument in order for the query to happen under that transaction @see <span><a href="class/src/transaction.js~Transaction.html">Transaction</a></span></p> <p>If you have <a href="https://github.com/Jeff-Lewis/cls-hooked">CLS</a> enabled, the transaction will automatically be passed to any query that runs within the callback</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Transaction options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.type</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: 'DEFERRED'</li></ul></td> <td data-ice="description"><p>See <code>Sequelize.Transaction.TYPES</code> for possible options. Sqlite only.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.isolationLevel</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>See <code>Sequelize.Transaction.ISOLATION_LEVELS</code> for possible options</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.deferrable</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Sets the constraints to be deferred or immediately checked. See <code>Sequelize.Deferrable</code>. PostgreSQL Only</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.readOnly</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>Whether this transaction will only be used to read data. Used to determine whether sequelize is allowed to use a read replication server.</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li> <li>default: false</li></ul></td> <td data-ice="description"><p>A function that gets executed while running the query to log the sql.</p> </td> </tr> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">autoCallback</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The callback is called with the transaction object, and should return a promise. If the promise is resolved, the transaction commits; if the promise rejects, the transaction rolls back</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="example"> <h4>Example:</h4> <div class="example-doc" data-ice="exampleDoc"> <pre class="prettyprint source-code"><code data-ice="exampleCode"> try { const transaction = await sequelize.transaction(); const user = await User.findOne(..., { transaction }); await user.update(..., { transaction }); await transaction.commit(); } catch { await transaction.rollback() }</code></pre> </div> <div class="example-doc" data-ice="exampleDoc"> <div class="example-caption" data-ice="exampleCaption">A syntax for automatically committing or rolling back based on the promise chain resolution is also supported</div> <pre class="prettyprint source-code"><code data-ice="exampleCode"> try { await sequelize.transaction(transaction => { // Note that we pass a callback rather than awaiting the call with no arguments const user = await User.findOne(..., {transaction}); await user.update(..., {transaction}); }); // Committed } catch(err) { // Rolled back console.error(err); }</code></pre> </div> <div class="example-doc" data-ice="exampleDoc"> <div class="example-caption" data-ice="exampleCaption">To enable CLS, add it do your project, create a namespace and set it on the sequelize constructor:</div> <pre class="prettyprint source-code"><code data-ice="exampleCode"> const cls = require('cls-hooked'); const namespace = cls.createNamespace('....'); const Sequelize = require('sequelize'); Sequelize.useCLS(namespace); // Note, that CLS is enabled for all sequelize instances, and all instances will share the same namespace</code></pre> </div> </div> </div> <div class="detail" data-ice="detail"> <h3 data-ice="anchor" id="instance-method-truncate"> <span class="access" data-ice="access">public</span> <span data-ice="async">async</span> <span class="code" data-ice="name">truncate</span><span class="code" data-ice="signature">(options: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></span> <span class="right-info"> <span data-ice="source"><span><a href="file/src/sequelize.js.html#lineNumber876">source</a></span></span> </span> </h3> <div data-ice="description"><p>Truncate all tables defined through the sequelize models. This is done by calling <code>Model.truncate()</code> on each model.</p> </div> <div data-ice="properties"><div data-ice="properties"> <h4 data-ice="title">Params:</h4> <table class="params"> <thead> <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr> </thead> <tbody> <tr data-ice="property" data-depth="0"> <td data-ice="name" class="code" data-depth="0">options</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>The options passed to Model.destroy in addition to truncate</p> </td> </tr> <tr data-ice="property" data-depth="1"> <td data-ice="name" class="code" data-depth="1">options.logging</td> <td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span> | <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td> <td data-ice="appendix"><ul><li>optional</li></ul></td> <td data-ice="description"><p>A function that logs sql queries, or false for no logging</p> </td> </tr> </tbody> </table> </div> </div> <div class="return-params" data-ice="returnParams"> <h4>Return:</h4> <table> <tbody> <tr> <td class="return-type code" data-ice="returnType"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></span></td> </tr> </tbody> </table> <div data-ice="returnProperties"> </div> </div> <div data-ice="see"><h4>See:</h4><ul><li><span><span><a href="class/src/model.js~Model.html#static-method-truncate">Model.truncate</a></span> for more information</span></li></ul></div> </div> </div> </div> <footer class="footer"> Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a> </footer> <script src="script/search_index.js"></script> <script src="script/search.js"></script> <script src="script/pretty-print.js"></script> <script src="script/inherited-summary.js"></script> <script src="script/test-summary.js"></script> <script src="script/inner-link.js"></script> <script src="script/patch-for-local.js"></script> <script>'use strict'; (() => { function toggleNavigationBar() { const navigationElements = document.getElementsByClassName('navigation'); for (let i = 0; i < navigationElements.length; ++i) { const navigationElement = navigationElements[i]; navigationElement.classList.toggle('open'); } } // Hamburger button - toggles the navigation bar const hamburger = document.getElementById('navigationHamburger'); hamburger.addEventListener('click', () => { toggleNavigationBar(); }); // Each link in the navigation bar - closes the navigation bar const navigationLinks = document.querySelectorAll('.navigation a'); for (let i = 0; i < navigationLinks.length; ++i) { const linkElement = navigationLinks[i]; linkElement.addEventListener('click', () => { toggleNavigationBar(); }); } })(); </script></body></html>