Download server/app/controller/onekey.js from jimlv/ssh: direct link, hf CLI and curl.
- Browser
- Download file 733 Bytes
-
https://huggingface.co/spaces/jimlv/ssh/resolve/main/server/app/controller/onekey.js
- Command line
-
hf download hf://spaces/jimlv/ssh/server/app/controller/onekey.js
-
curl -L -o onekey.js https://huggingface.co/spaces/jimlv/ssh/resolve/main/server/app/controller/onekey.js
733 Bytes
| const { OnekeyDB } = require('../utils/db-class') | |
| const onekeyDB = new OnekeyDB().getInstance() | |
| async function getOnekeyRecord({ res }) { | |
| let data = await onekeyDB.findAsync({}) | |
| data = data.map(item => { | |
| return { ...item, id: item._id } | |
| }) | |
| data?.sort((a, b) => Number(b.startDate) - Number(a.startDate)) | |
| res.success({ data }) | |
| } | |
| const removeOnekeyRecord = async ({ res, request }) => { | |
| let { body: { ids } } = request | |
| if (ids === 'ALL') { | |
| await onekeyDB.removeAsync({}, { multi: true }) | |
| res.success({ data: '移除全部成功' }) | |
| } else { | |
| await onekeyDB.removeAsync({ _id: { $in: ids } }) | |
| res.success({ data: '移除成功' }) | |
| } | |
| } | |
| module.exports = { | |
| getOnekeyRecord, | |
| removeOnekeyRecord | |
| } | |