简体   繁体   中英

Use an existing database with AdonisJS

I'm looking to use AdonisJS with an existing database I made. I only see tutorials and documentation on creating/migrating new tables. I'm struggling to find online content that shows how to integrate Adonis with a previously created SQL database.

I heard it was possible but I do not know how to go about this and fetch the models and sync the orm. How may I do this?

Adonis can work without migration.

The only thing you have to do on Adonis side is to create your model. Be careful and choose right field types.

To sync your database and models, you have to do it manually. Just create a new model with all fields and the right table name and it's done.

After that you can use your models to query database (like before with migrations)

look at this: https://github.com/ME-Studio/mysql-workbench-export-adonisjs-migrations

ME-Studio: created a MySQL workbench plugin to automatically generate your migrations from an existing database schema. Hope this will be useful when you're porting to Adonis. mysql-workbench-export-adonisjs-migrations Feedbacks are welcome.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM