Home > Mobile >  Is it possible to access an SQL database migrated using Django with a JavaScript ORM instead of raw
Is it possible to access an SQL database migrated using Django with a JavaScript ORM instead of raw

Time:07-14

Suppose that I have an app where the models have been created using Django ORM and Django acts like an API for authentication and gives control to the relation model User using its ORM. At the same time, we want to use Express JS to continuously update a field in one the User model for some feature that requires performance. Is it possible to use a JavaScript ORM with Express JS to update such field? If yes, then how?

CodePudding user response:

In the following tutorial tutorial for Golang, the database is created using SQL and a table called go_test_model is created. Then he uses the struct called GoTestModel to create a row in the table go_test_model.

This basically means that if we create an app called api in Django and add in it a model called Example, then to handle that model in Golang we just create a struct called ApiExample and from there we can have CRUD access to the same table, there might be some conflicts in the fields datatypes between GORM and Django ORM but integrity is still applied in the database itself.

So this particular example solves my problem with Golang and can be replicated using Node JS.

CodePudding user response:

You can use Sequelize for using native functions for performing queries instead of writing raw queries.

Also, please refer to Models section to define models.

  • Related