Prathamesh Jadhav
Prathamesh Jadhav

Reputation: 55

How insert bulk upload in postgresql using Sequelize?

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)
})

Upvotes: 0

Views: 498

Answers (1)

Adrian Klaver
Adrian Klaver

Reputation: 19570

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.

Upvotes: 0

Related Questions