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 typeorm sample for javascript #75

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

dengfuping
Copy link
Contributor

@dengfuping dengfuping commented Oct 31, 2024


Connect to OceanBase with TypeORM

This document describes how to connect to OceanBase with TypeORM.

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/typeorm

Install dependencies:

npm install

Modify the connection string in the index.ts file:

const dataSource = new DataSource({
  type: "mysql",
  url: "mysql://root:@127.0.0.1:2881/test",
  entities: [User],
  synchronize: true,
});

Execute index.ts:

npx ts-node index.ts

The output should be as follows, indicating successful execution:

[ User { 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 changed the title feat: Add typeorm sample for javascript feat: Add typeorm sample for javascript application Dec 2, 2024
@dengfuping dengfuping force-pushed the typeorm-sample branch 2 times, most recently from 944ee1b to c2bce1b Compare December 2, 2024 07:38
@dengfuping dengfuping changed the title feat: Add typeorm sample for javascript application feat: Add typeorm sample for javascript Dec 2, 2024
@dengfuping dengfuping force-pushed the typeorm-sample branch 2 times, most recently from 6832726 to 22a79cd Compare December 2, 2024 13:02
Copy link
Member

@whhe whhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution!

@whhe whhe merged commit e50330e into oceanbase:master Dec 18, 2024
4 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