This file contains hidden or 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
-- recursive query | |
WITH RECURSIVE region_hierarchy AS ( | |
-- Basis Case: Ambil semua provinsi (parent_id IS NULL) | |
SELECT id, name, parent_id, population | |
FROM regions | |
WHERE parent_id IS NULL | |
UNION | |
-- Recursive Case: Tambahkan semua kota (child) dalam provinsi | |
SELECT r.id, r.name, r.parent_id, r.population | |
FROM regions r |
This file contains hidden or 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
INSERT INTO regions (id, name, parent_id, population) VALUES | |
(1, 'Jawa Barat', NULL, 0), -- Provinsi | |
(2, 'Jakarta', NULL, 0), -- Provinsi | |
(3, 'Bandung', 1, 3000000), -- Kota di Jawa Barat | |
(4, 'Bekasi', 1, 2800000), -- Kota di Jawa Barat | |
(5, 'Depok', 1, 2200000), -- Kota di Jawa Barat | |
(6, 'Jakarta Pusat', 2, 1100000), -- Kota di Jakarta | |
(7, 'Jakarta Selatan', 2, 2000000), -- Kota di Jakarta | |
(8, 'Jawa Timur', null, 0), | |
(9, 'Malang', 8, 889359), |
This file contains hidden or 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
CREATE TABLE regions ( | |
id SERIAL PRIMARY KEY, | |
name TEXT NOT NULL, | |
parent_id INT REFERENCES regions(id), -- NULL jika ini adalah Provinsi | |
population INT DEFAULT 0 -- Jumlah penduduk | |
); |
This file contains hidden or 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", | |
"productId": "57", | |
"categoryId": "56", | |
"productAmount": "100000", | |
"mobileNumber": "" | |
} |
This file contains hidden or 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
{ | |
"voucherStockCategory": "AS:600" | |
} |
This file contains hidden or 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
{ | |
"amount": 25000, | |
"itemId": "XL:PRE" | |
} |
This file contains hidden or 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
{ | |
"item": "freefire_720", | |
"product": "free_fire" | |
} | |
// jika keterangan product tidak ada di excel, maka isikan seperti berikut : | |
// di develop isikan host2host: false, sedangkan jika di production isikan host2host: true | |
{ | |
"item": "RBLX10", | |
"host2host": true |
This file contains hidden or 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
// group object by property | |
const books = [ | |
{ | |
title: "Sebuah Seni Untuk Bersikap Bodo Amat", | |
author: "Mark Manson" | |
}, | |
{ | |
title: "Segala - galanya Ambyar", | |
author: "Mark Manson" | |
}, |
This file contains hidden or 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
var numbers = [10, 20, 30, 40]; | |
var sum = numbers.reduce((acc, current) => acc + current, 0); | |
console.log(sum); // hasilnya 100 |
This file contains hidden or 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 |
NewerOlder