N
Neon2y ago
generous-apricot

Neon and Sequelize?

I have an existing node.js web app that uses Sequelize (https://www.npmjs.com/package/sequelize) to interface with my postGres db. Is Sequelize compatible with Neon?
npm
sequelize
Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.. Latest version: 6.37.3, last published: 2 days ago. Start using sequelize in your project by ru...
5 Replies
adverse-sapphire
adverse-sapphire2y ago
We've got a guide for that: https://neon.tech/docs/guides/sequelize
Neon
Schema migration with Neon Postgres and Sequelize - Neon Docs
Sequelize is a promise based Node.js ORM that supports multiple relational databases. In this guide, we'll explore how to use Sequelize ORM with a Neon Postgres database in a JavaScript project. We'll...
generous-apricot
generous-apricotOP2y ago
In my current app, I tell Sequelize about my schema like this: const db = new Sequelize([.....] const EmailSignupsModel = db.define('email_signups', { id: {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true}, createdAt: {type: Sequelize.DATE}, updatedAt: {type: Sequelize.DATE}, name_first: {type: Sequelize.STRING}, email_address: {type: Sequelize.STRING}, confirmation_code: {type: Sequelize.STRING}, confirmation_received: {type: Sequelize.BOOLEAN, defaultValue: false} }); From the Neon docs, I see this: const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => {[.....] Is that a replacement for my current Sequelize schema set up, or, in addition to my current Sequelize schema set up?
foreign-sapphire
foreign-sapphire2y ago
@Vik I believe this is just a difference in the way the code is structured. Are you running into a specific issue running the code? As far as I know you should be able to create a sequelize instance and pass your Neon connection string and it'll work const sequelize = new Sequelize(DATABASE_URL)
generous-apricot
generous-apricotOP2y ago
Okay, thanks Evan. I just heard about Neon today and it sounds amazing. I'm evaluating what it would take to move my app to Neon.
foreign-sapphire
foreign-sapphire2y ago
Awesome! If you run into any blockers, we're here to help

Did you find this page helpful?