12345678910111213141516171819202122232425262728293031323334 |
- import connection from "./base.js";
- /*
- `file_id` VARCHAR(100) NOT NULL, -- file_id 长度为 100
- `md5` VARCHAR(32) NOT NULL, -- MD5 长度为 32
- `mimetype` VARCHAR(255) NOT NULL, -- mimetype 长度为 255
- `size` INT NOT NULL,
- `name` VARCHAR(255) DEFAULT NULL,
- `path` VARCHAR(255) DEFAULT NULL,
-
- */
- export async function files_insert({
- file_id = "",
- md5 = "",
- mimetype = "",
- size = "",
- name = "",
- path = "",
- }) {
- return new Promise(async (resolve, reject) => {
- try {
- const sql = `
- INSERT INTO files (file_id, md5, mimetype, size, name, path)
- VALUES (?, ?, ?, ?, ?, ?)
- `;
- const values = [file_id, md5, mimetype, size, name, path];
- // 直接接收 execute 返回的内容
- const result = await connection.execute(sql, values);
- return resolve(result);
- } catch (err) {
- return resolve(false);
- }
- });
- }
|