data_insert.js 582 Bytes
const db = require('../model/db');
const profanity1 = require('./profanity1.json');
const profanity2 = require('./profanity2.json');

const insertDB = async () => {
    let sumOfProfanity = [...new Set([...profanity1.profanity,...profanity2.profanity])];
    sumOfProfanity = sumOfProfanity.map((element) => [element]);
    try {
        const insertQuery = "insert into profanity (content) values ?;";
        const result = await db.query(insertQuery, [sumOfProfanity]);
        console.log('yes');
    } catch (err) {
        console.log(err);
    }
}

module.exports = insertDB;