本文整理汇总了TypeScript中Sequelize.Sequelize.authenticate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Sequelize.authenticate方法的具体用法?TypeScript Sequelize.authenticate怎么用?TypeScript Sequelize.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequelize.Sequelize
的用法示例。
在下文中一共展示了Sequelize.authenticate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
return new Promise((resolve, reject) => {
this._db.authenticate().then(() => {
// initialize models
// create model associations
this._db.sync().then(() => {
resolve(true);
}).catch((ex: Error) => {
reject(ex);
});
}).catch((ex: Error) => {
reject(ex);
});
});
示例2: Sequelize
import {ApolloServer, gql} from "apollo-server";
import { Sequelize } from "sequelize";
const sequelize = new Sequelize(process.env.POSTGRES_DB, process.env.POSTGRES_USER, process.env.POSTGRES_PASSWORD, {
host: process.env.POSTGRES_HOST,
dialect: "postgres",
});
sequelize
.authenticate()
.then(() => {
console.log("Connection has been established successfully.");
})
.catch((err) => {
console.error("Unable to connect to the database:", err);
});
const books = [
{
title: "Harry Potter and the Chamber of Secrets",
author: "J.K. Rowling",
},
{
title: "Jurassic Park",
author: "Michael Crichton",
},
];
const typeDefs = gql`
type Book {
title: String