Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fetching foreign key data in sequelize

Generic :

TableB.belongsTo(models.TableA, { foreignKey: 'someID', targetKey: 'notTableAID' } );

TableA.hasOne(TableB, {
  sourceKey: 'someNonPrimaryKeyColumnOnTheSOurceModel',
  foreignKey: 'matchingColumnOnTheTargetModel'
});



Example : 
// associations
assetAuditSubmissionsModel.hasOne(assetInfoModel, {
  foreignKey: "assetSerialNumber",
  sourceKey: "assetSerialNumber",
});

assetInfoModel.belongsTo(assetAuditSubmissionsModel, {
  foreignKey: "assetSerialNumber",
  targetKey: "assetSerialNumber",
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: .sort javascript 
Javascript :: removeclass multiple 
Javascript :: how to find network there is no network react native 
Javascript :: javascript - get the filename and extension from input type=file 
Javascript :: on mouse not over jquiery 
Javascript :: a function that calls itself js 
Javascript :: js styles when clicked 
Javascript :: jquery get selected checkbox value array 
Javascript :: 3 letter months javascript array 
Javascript :: how to control playback speed in javascript 
Javascript :: javascript check typeof array 
Javascript :: killall node windows 
Javascript :: first and last char vowel reg exp same char 
Javascript :: installe datatable to reactjs project 
Javascript :: how to find the smallest two numbers in an array javascript 
Javascript :: nodejs mysql insert object query 
Javascript :: puppeteer get attribute 
Javascript :: using iframe in chrome console 
Javascript :: remove brackets from array javascript 
Javascript :: open modal in jqwuery 
Javascript :: last element in javascript 
Javascript :: currency convertor api in javascript 
Javascript :: js get random hex color 
Javascript :: slickcdn 
Javascript :: react use same useState for multiple inputs 
Javascript :: sotre json on chrome storage 
Javascript :: check if new user in firebase react 
Javascript :: typeorm where in 
Javascript :: method to look for objects in arrays by id 
Javascript :: add event listener on width screen resize 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =