This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Sequelize = require(‘sequelize’); | |
const sequelize = new Sequelize( | |
"nama_database", | |
"username", | |
"password", | |
{ | |
//contoh | |
host: "localhost", | |
dialect: "mysql" | "sqlite" | "postgres" | "mssql" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// models/Movie.js | |
const Sequelize = require("sequelize") | |
const sequelize = require("../config/db") | |
const Movie = sequelize.define( | |
"movie", | |
{ | |
id_movie: { | |
type: Sequelize.INTEGER, | |
primaryKey: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controllers/movieController.js | |
const Movie = require("../models/Movie") | |
module.exports = { | |
index: function(req, res) { | |
Movie.findAll().then(function(rows) { | |
res.render("movie/index", { data: rows }) | |
}) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// definisikan dependency yang dibutuhkan | |
const express = require("express"); | |
const app = express(); | |
const multer = require("multer"); | |
//untuk menambahkan path | |
const path = require("path"); | |
// menentukan lokasi pengunggahan | |
const diskStorage = multer.diskStorage({ | |
destination: function (req, file, cb) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const book = { | |
"title": "Manusia Setengah Salmon", | |
"author": "Raditya Dika", | |
"publisher": { | |
"name": "Gagas Media", | |
"address": "Jakarta Selatan" | |
} | |
} | |
const title = book.title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const book = { | |
"title": "Manusia Setengah Salmon", | |
"author": "Raditya Dika", | |
"publisher": { | |
"name": "Gagas Media", | |
"address": "Jakarta Selatan" | |
} | |
} | |
// destructuring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const student = [ | |
{ id: 11, name: "Smith" }, | |
{ id: 12, name: "Roger" }, | |
{ id: 13, name: "Romeo" }, | |
{ id: 14, name: "Jesicca" }, | |
{ id: 15, name: "Ellen" } | |
]; | |
// // what we need ['smith', 'Roger', 'Romeo', 'Jesicca','Ellen'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type":"prepaid", | |
"productCode": "AXIS25", | |
"productName": "Axis 25.000", | |
"productType": "mobile" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const books = [ | |
{ | |
title: "Sebuah Seni Untuk Bersikap Bodo Amat", | |
author: "Mark Manson" | |
}, | |
{ | |
title: "Segala - galanya Ambyar", | |
author: "Mark Manson" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for loop | |
var numbers = [10, 20, 30, 40]; | |
var sum = 0; | |
for (var i = 0; i < numbers.length; i++) { | |
sum += numbers[i]; | |
} | |
console.log(sum); // hasilnya adalah 100 |
OlderNewer