Spaces:
Sleeping
Sleeping
Create models/ApiKey.js
Browse files- models/ApiKey.js +13 -0
models/ApiKey.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const db = require('../database');
|
2 |
+
|
3 |
+
const ApiKey = {
|
4 |
+
create: (userId, key, callback) => {
|
5 |
+
const sql = `INSERT INTO api_keys (user_id, api_key) VALUES (?, ?)`;
|
6 |
+
db.query(sql, [userId, key], callback);
|
7 |
+
},
|
8 |
+
findByUserId: (userId, callback) => {
|
9 |
+
db.query('SELECT * FROM api_keys WHERE user_id = ?', [userId], callback);
|
10 |
+
}
|
11 |
+
};
|
12 |
+
|
13 |
+
module.exports = ApiKey;
|