Posts

Showing posts with the label Academe

Sequelize

Image
 First install sequelize install mysql2 before it Creating Database rules for seuqlize Now define Model  Now for syncing models into database and creating table for them we need to use sync function First import sequelize  Next use sequelize sync function  Now create a function to create a product using Product model  Now if we go to add product page we can than create product using the above function  Get all Products without any limitation using findAll() method    Get Single Product  We are using findById but now it has been replaced findByPk(). Also unlike the prev way where we are not getting array of product and only single product so we are replacing the array boilerplate. We have also option of finding multiple product option. But one issue is for fetching single product is that we still have to use array as the products are fetched as array.  Updating Edit Product Page 1)First check if it is edit mode and next get product like ...