fix: cloud wip

This commit is contained in:
ikechan8370 2025-04-05 23:06:24 +08:00
parent f521e0ede8
commit 5c1b74bfb1
7 changed files with 226 additions and 7 deletions

View file

@ -61,6 +61,43 @@ export class LowDBChannelStorage extends ChaiteStorage {
return list.map(item => new Channel({}).fromString(JSON.stringify(item)))
}
/**
*
* @param {Record<string, unknown>} filter
* @returns {Promise<import('chaite').Channel[]>}
*/
async listItemsByEqFilter (filter) {
const allList = await this.listItems()
return allList.filter(item => {
for (const key in filter) {
if (item[key] !== filter[key]) {
return false
}
}
return true
})
}
/**
*
* @param {Array<{
* field: string;
* values: unknown[];
* }>} query
* @returns {Promise<import('chaite').Channel[]>}
*/
async listItemsByInQuery (query) {
const allList = await this.listItems()
return allList.filter(item => {
for (const { field, values } of query) {
if (!values.includes(item[field])) {
return false
}
}
return true
})
}
async clear () {
await this.collection.deleteAll()
}