Performance: CRUD operations with Sequelize
This concept affects server response time and database query efficiency, impacting how fast data changes reflect on the page.
Jump into concepts and practice - no test required
const users = await User.findAll({ attributes: ['id', 'name'], limit: 50 });
const users = await User.findAll();| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fetching all records without limit | N/A | N/A | N/A | [X] Bad |
| Fetching limited fields and records | N/A | N/A | N/A | [OK] Good |
| Updating without existence check | N/A | N/A | N/A | [X] Bad |
| Updating after existence check | N/A | N/A | N/A | [OK] Good |
| Deleting all records accidentally | N/A | N/A | N/A | [X] Bad |
| Deleting targeted record | N/A | N/A | N/A | [OK] Good |
create() method is used to add new records to the database.create() -> Option Ccreate() [OK]const users = await User.findAll({ where: { age: { [Op.gt]: 18 } } });
console.log(users.length);console.log(users.length) output?await User.destroy(id);
[Op.lt] with a Date object inside the where clause.