0

I use Sequelize to write ORM queries in nodejs, but now i want to insert data in bulk format from Data.js file which contains data , But i getting error in my console error: ......... Executing (default): SELECT 1+1 AS result not inserted...ReferenceError: myusers is not defined so tell me how to solve this?

const restify=require('restify')
const server=restify.createServer()
const Data=require('./Data')
//connection with database
const Sequelize=require('sequelize')
const connection = new Sequelize('emadb', 'postgres', 'Groot@2498', {
    host: 'localhost',
    dialect:  'postgres' 
  });
connection
.sync({
    logging:console.log('.........')
})
.then(()=>{
    myusers.bulkCreate(Data)
    server.listen(8080,function(){
        console.log('insert info server started')
    })
})
.catch(err=>{
    console.log('not inserted...'+err)
})

1 Answer 1

0

The error:

ReferenceError: myusers is not defined

is pretty specified You have:

myusers.bulkCreate(Data)

but I (nor the program) don't see anywhere you define myusers before you use it.

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

2 Comments

myusers is table in my postgresql database
That may be so, but the program has to know about it. I'm not that familiar with Sequelize, but it uses models to map database tables: Models. Usage. So you need to make the program aware of the model you are using in order to get at the bulkCreate() on the model.

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.