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 drizzle sample for javascript #76

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

dengfuping
Copy link
Contributor

@dengfuping dengfuping commented Oct 31, 2024


Connect to OceanBase with Drizzle

This document describes how to connect to OceanBase with Drizzle.

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

Install dependencies:

npm install

Modify the connection string in the .env file:

DATABASE_URL="mysql://root:@127.0.0.1:2881/test"

Synchronize the users model defined in db/schema.ts to the database:

npx drizzle-kit push

Execute index.ts:

npx ts-node index.ts

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)

@whhe
Copy link
Member

whhe commented Oct 31, 2024

If the component can be executed by command line, please add a run.sh script for it to test it on GitHub Action. Otherwise please add the module to applications directory.

@dengfuping
Copy link
Contributor Author

dengfuping commented Dec 2, 2024

If the component can be executed by command line, please add a run.sh script for it to test it on GitHub Action. Otherwise please add the module to applications directory.

@whhe Done. run.sh is added.

@dengfuping dengfuping changed the title feat: Add drizzle sample for javascript feat: Add drizzle sample for javascript application Dec 2, 2024
@dengfuping dengfuping changed the title feat: Add drizzle sample for javascript application feat: Add drizzle sample for javascript Dec 2, 2024
@dengfuping dengfuping force-pushed the drizzle-sample branch 7 times, most recently from a67b7a2 to 08c124d Compare December 9, 2024 03:48
@dengfuping
Copy link
Contributor Author

@dengfuping dengfuping force-pushed the drizzle-sample branch 2 times, most recently from 69beb9d to 95d03da Compare December 17, 2024 07:15
@@ -17,8 +17,12 @@ jobs:
module:
- name: 'mysql2'
with_oceanbase_container: true
- name: 'drizzle'
with_oceanbase_container: true
oceanbase_image_tag: '4.2.3_BETA'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

only oceanbase-ce >= 4.2.3 supports serial data type and that is required for Drizzle.

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.

Great work!

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