0

I'm trying for a long time to do a raw query using sequelize. Following the guide on web, I write this piece of code:

 var sequelize = new Sequelize('name', 'user', 'password');
 var sql = '--query---';
 return sequelize.query(sql,  { raw: true });

But in this way, the number of results returned is not correct. Also, in a component, how can I manage the data returned?

Can you help me?

Thanks

1 Answer 1

1

I used to use this to select customers given a Stripe ID.

var Sequelize = require('sequelize'),
           sequelize = new Sequelize('name', 'user', 'password', {
                   dialect: "mysql",
                   port: 3306,
           })

           var table = "users";

   sequelize
           .authenticate()
           .complete(function (err) {

                   sequelize.query(
                           "SELECT * FROM users WHERE stripe_id = :status ", null, {
                                   raw: true
                           }, {
                                   status: customer_id
                           }
                   ).then(function (myTableRows) {

                           // Query Response


                   });

           });

Personally I've moved away from sequelize to RethinkDB and am very happy. They have pretty in-depth javascript support.

https://www.rethinkdb.com/api/javascript/js/

Sign up to request clarification or add additional context in comments.

1 Comment

Your solution generate "sequelize.authenticate(...).complete is not a function" error. ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.