Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

define a sequelize like below: var Program=sequelize.define('Program',{ programCode:{ type:Sequelize.STRING, primaryKey:true }, programName:Sequelize.STRING, }, module.exports.addProgram=function(programData){ return new Promise((resolve,reject)=>{ for ( var i in programData){ if(programData[i]==)

define a sequelize like below:

 

var Program=sequelize.define('Program',{

programCode:{

type:Sequelize.STRING,

primaryKey:true

},

programName:Sequelize.STRING,

},

module.exports.addProgram=function(programData){

return new Promise((resolve,reject)=>{

for ( var i in programData){

if(programData[i]=="")

programData[i]=null;

};

Program.create({

programCode:programData.programCode,

programName:programData.programName,

}) .then((data) => {

console.log("data:", data)

resolve(data);}

)

.catch((err) => {

reject ("Unable to Add the program");

return;

});

});

}

I know the programCode primaryKey should not be null, but if I input null in programCode, I will get some error. How could I handle this error?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Communications and Networking

Authors: Behrouz A. Forouzan

5th edition

73376221, 978-0073376226

More Books

Students also viewed these Computer Network questions

Question

DEFINE Critical chain project management (CCPM)

Answered: 1 week ago