β¬οΈ Main Note
https://docs.google.com/document/d/1c3LEm0IKmI6y--c3nGdjaxAmZISq7eHd3TfjwD-M1fc/edit
Today, I'm trying to make productTags API. This one's in the format of manyToMany in database.
productTags will get the input in the form of array. => productTags: ["#new","#hi"]
async create({ createProductInput }) {
const {
productSaleslocation,
productCategoryId,
productTags,
...restProduct
} = createProductInput; // dividing createProductInput into several variables so that things can be assigned separately.
const result = await this.productSaleslocationRepository.save({
...productSaleslocation,
});
// productTags : ["#wow","#chocolate","#yum"]
// =-=-=-=-=-= productTags =-=-=-=-=-=
const result2 = [];
for (let i = 0; i < productTags.length; i++) {
const tagName = productTags[i].replace('#', '');
// ----------- tag overlap check -----------
const prevTag = await this.productTagRepository.findOne({
name: tagName,
}); // Check whether the tag name already exists in database (= original tag)
if (prevTag) {
// If original tag exists
result2.push(prevTag);
} else {
// If the original tag doesn't exist
const newTag = await this.productTagRepository.save({ name: tagName });
result2.push(newTag);
}
}
Memory: Data are saved as variables, so when you shut down the computer, all data are removed.
Disk: Data are saved as text, which is saved inside the computer itself.
π Vertical Partitioning
Data are saved column by column
ex) Things are saved in big categories: user data, payment data, etc
π Horizontal Partitioning : Sharding
Normalized database(μ κ·νλ DB: 1NF, 2NF...) are saved to reduce the data size.
βοΈ Since database is disk-based, the speed of calling the data is slow.
So we're gonna use Redis, which is memory-based database.
login info : token info
.Or just save the login info in object-form and save the login info that's encrypted.
Encrypt <==> Decode
ex) γ± - r, γ΄ - s, γ· - e β¦ // βλλβ : βehdehdβ
--> This one's able to be hacked by the hackers.
So JWT is mostly used for encoding the info.
JWT : JSON Web Token --> Decoding website
Here in JWT, key is the string-type password
--> Using this key, only the one who knows the password is able to access for decoding.
β οΈ Warning
Since anyone could decode, important data shouldn't be saved; things like user's personal information.