Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const connection = require('../config/database')
- const bodyParser = require('body-parser')
- exports.ShowPengeluaran = (req, res) => {
- const sql = 'SELECT * FROM pengeluaran'
- connection.query(sql, (error, results) => {
- if(error) throw error
- res.json(results)
- })
- }
- exports.PengeluaranID = (req, res) => {
- const id = req.params.id
- const sql = 'SELECT * FROM pengeluaran WHERE id=?'
- connection.query(sql, [id], (error, results) => {
- if(error) throw error
- res.json(results)
- })
- }
- exports.AddPengeluaran = (req, res) => {
- const id_nik = req.body.id_nik
- const pengeluaran = req.body.pengeluaran
- const tanggal_pengeluaran = req.body.tanggal_pengeluaran
- const sql = 'INSERT INTO pengeluaran(id_nik,pengeluaran,tanggal_pengeluaran) VALUES(?,?,?)'
- connection.query(sql, [id_nik, pengeluaran, tanggal_pengeluaran], (error, results) => {
- if(error) throw error
- res.json(results)
- })
- }
- exports.EditPengeluaran = (req, res) => {
- const id = req.params.id
- const id_nik = req.params.id_nik
- const pengeluaran = req.body.pengeluaran
- const tanggal_pengeluaran = req.body.tanggal_pengeluaran
- const sql = 'UPDATE pengeluaran SET id_nik=?, pengeluaran=?, tanggal_pengeluaran=? WHERE id=?'
- connection.query(sql, [id_nik,pengeluaran,tanggal_pengeluaran,id], (error, results) => {
- if(error) throw error
- res.json(results)
- })
- }
- exports.DeletePengeluaran = (req, res) => {
- const id = req.params.id
- const id_nik = req.body.id_nik
- const pengeluaran = req.body.pengeluaran
- const tanggal_pengeluaran = req.body.tanggal_pengeluaran
- const sql = 'DELETE FROM pengeluaran WHERE id=?'
- connection.query(sql, [id], (error, results) => {
- if(error) throw error
- res.json(results)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement