Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add sequelize sample for javascript #74

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

dengfuping
Copy link
Contributor

@dengfuping dengfuping commented Oct 31, 2024


Connect to OceanBase with Sequelize

This document describes how to connect to OceanBase with Sequelize.

Preparation

Make sure Node.js and npm are installed.

Usage

Clone the project and navigate to the appropriate directory:

git clone [email protected]:oceanbase/ob-samples.git
cd javascript/sequelize

Install dependencies:

npm install

Modify the connection string in the index.js file:

const sequelize = new Sequelize("mysql://root:@127.0.0.1:2881/test", {
  dialect: "mysql",
  logging: false,
});

Execute index.js:

node index.js

The output should be as follows, indicating successful execution:

[
  {
    "id": 1,
    "email": "[email protected]",
    "name": "Alice"
  }
]

Check the corresponding users table and the data has been inserted:

mysql> select * from users;
+----+---------------------+-------+
| id | email               | name  |
+----+---------------------+-------+
|  1 | [email protected] | Alice |
+----+---------------------+-------+
1 row in set (0.01 sec)

@dengfuping dengfuping force-pushed the sequelize-sample branch 3 times, most recently from a6e825b to 2187649 Compare October 31, 2024 09:54
@dengfuping dengfuping changed the title feat: Add sequelize sample for javascript feat: Add sequelize sample for javascript application Dec 2, 2024
@dengfuping dengfuping changed the title feat: Add sequelize sample for javascript application feat: Add sequelize sample for javascript Dec 2, 2024
@whhe whhe merged commit 8393d65 into oceanbase:master Dec 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants