Convert UserFetch

This commit is contained in:
Adria Navarro 2025-01-02 13:38:38 +01:00
parent c7255362b0
commit 54d5047b34
1 changed files with 8 additions and 3 deletions

View File

@ -2,9 +2,10 @@ import { get } from "svelte/store"
import DataFetch from "./DataFetch.js" import DataFetch from "./DataFetch.js"
import { TableNames } from "../constants" import { TableNames } from "../constants"
import { utils } from "@budibase/shared-core" import { utils } from "@budibase/shared-core"
import { Table, UIFetchAPI } from "@budibase/types"
export default class UserFetch extends DataFetch { export default class UserFetch extends DataFetch<{ tableId: string }, {}> {
constructor(opts) { constructor(opts: { API: UIFetchAPI; datasource: Table; options?: {} }) {
super({ super({
...opts, ...opts,
datasource: { datasource: {
@ -27,12 +28,16 @@ export default class UserFetch extends DataFetch {
} }
} }
getSchema(_datasource: any, definition: Table | null) {
return definition?.schema
}
async getData() { async getData() {
const { limit, paginate } = this.options const { limit, paginate } = this.options
const { cursor, query } = get(this.store) const { cursor, query } = get(this.store)
// Convert old format to new one - we now allow use of the lucene format // Convert old format to new one - we now allow use of the lucene format
const { appId, paginated, ...rest } = query || {} const { appId, paginated, ...rest } = query || ({} as any) // TODO
const finalQuery = utils.isSupportedUserSearch(rest) const finalQuery = utils.isSupportedUserSearch(rest)
? query ? query
: { string: { email: null } } : { string: { email: null } }