Skip to content

suvelocity/challenge-sequelize-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Challenge-Sequelize

Description

In this challenge we will be building basic ORM functionallity base on Sequelize using mysql2


Main Goal

Implementing the next functions:

  • Insert ()

  • BulkInsert ()

  • FindAll ()

  • FindOne ()

  • FindByPk ()

  • Update ()

  • soft/hard Destroy ()

  • Restore ()


First Steps

  1. Clone template repository

  2. Run $npm i

  3. If you want to run the tests locally, connect to your MySql in the test connection statment, which is located in the beforeAll() in the main test. Enter you password and create empty DB called db_test in your machine.

sql connection


Starting The Challenge

If you are not famillier with Sequelize syntax:

Insert

Model.Insert({... the object containing the value you want to insert})

Bulk Insert

Model.BulkInsert([... array with the objects you want to insert])

FindAll

Model.findAll({ ... the object containing the select query condition you want to apply})

FindOne

Model.FindOne({... the object containing the select query condition you want to apply})

FindByPK

Model.FindByPk(Priority Key)

Update

Model.Update({... the object containing the where condition, that you want to update})

Soft/Hard Destroy

Model.Destroy ({... the object containing the conditions for the rows that you want to delete, to hard delete add force:true})

Restore

Model.Restore ({... the object containing the conditions for the rows that you want to restore}, without object restor all)


General

Files and Folders:

Use The Template!

  • main class MySequelize in index.js, which located in the main folder

Operations:

  • folder called 'Op'. inside the folder you must have the file 'OpSymbols.js' (rest of the files is for your decision)

Op folder

  • 'OpSymbols.js' should export the object 'Op', as in the picture

Op export

  • so we can require it as follow in the test

Op require

  • and use it this way (like in sequelize...)

Op use

Include:

  • 'include' statment recieves the folowwing parameters:

Include params

  • 'include' statment should return nested array inside the original object, with key equel to the table name

  • [TextRow] is a playlist object

Include params


Submiting The Challenge

  1. The repository must be public and the solution must be in master/main branch

  2. Copy the relative url of the repository and paste in the submiting form.


Usefull Links

About

Challenge Sequelize Template

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •