Panel / models /ApiKey.js
Niansuh's picture
Create models/ApiKey.js
61b383a verified
raw
history blame contribute delete
385 Bytes
const db = require('../database');
const ApiKey = {
create: (userId, key, callback) => {
const sql = `INSERT INTO api_keys (user_id, api_key) VALUES (?, ?)`;
db.query(sql, [userId, key], callback);
},
findByUserId: (userId, callback) => {
db.query('SELECT * FROM api_keys WHERE user_id = ?', [userId], callback);
}
};
module.exports = ApiKey;