mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
feat: init v3
This commit is contained in:
parent
d6cb085c40
commit
531986b2dc
284 changed files with 618 additions and 405179 deletions
53
models/chaite/tool_settings_storage.js
Normal file
53
models/chaite/tool_settings_storage.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import ChatGPTStorage from '../storage.js'
|
||||
|
||||
/**
|
||||
* @returns {import('chaite').ToolSettingsStorage}
|
||||
*/
|
||||
export function createToolsSettingsStorage () {
|
||||
return new LowDBToolsSettingsStorage(ChatGPTStorage)
|
||||
}
|
||||
|
||||
class LowDBToolsSettingsStorage {
|
||||
/**
|
||||
*
|
||||
* @param { LowDBStorage } storage
|
||||
*/
|
||||
constructor (storage) {
|
||||
this.storage = storage
|
||||
/**
|
||||
* 集合
|
||||
* @type {LowDBCollection}
|
||||
*/
|
||||
this.collection = this.storage.collection('tool_settings')
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('chaite').ToolSettings} settings
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async saveToolSettings (settings) {
|
||||
await this.collection.insert(settings)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param { string } name
|
||||
* @returns {Promise<import('chaite').ToolSettings | null>}
|
||||
*/
|
||||
async getToolSettings (name) {
|
||||
return this.collection.findOne({ name })
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<import('chaite').ToolSettings[]>}
|
||||
*/
|
||||
async getAllToolSettings () {
|
||||
return this.collection.findAll()
|
||||
}
|
||||
|
||||
async deleteToolSettings (name) {
|
||||
await this.collection.delete({ name })
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue