2021-12-17 09:22:04 +01:00
|
|
|
import TableFetch from "./TableFetch.js"
|
|
|
|
import ViewFetch from "./ViewFetch.js"
|
|
|
|
import QueryFetch from "./QueryFetch.js"
|
|
|
|
import RelationshipFetch from "./RelationshipFetch.js"
|
2022-01-04 16:02:43 +01:00
|
|
|
import NestedProviderFetch from "./NestedProviderFetch.js"
|
|
|
|
import FieldFetch from "./FieldFetch.js"
|
|
|
|
import JSONArrayFetch from "./JSONArrayFetch.js"
|
2021-12-17 09:22:04 +01:00
|
|
|
|
|
|
|
const DataFetchMap = {
|
|
|
|
table: TableFetch,
|
|
|
|
view: ViewFetch,
|
|
|
|
query: QueryFetch,
|
|
|
|
link: RelationshipFetch,
|
2022-01-18 10:39:19 +01:00
|
|
|
|
|
|
|
// Client specific datasource types
|
2022-01-04 16:02:43 +01:00
|
|
|
provider: NestedProviderFetch,
|
|
|
|
field: FieldFetch,
|
|
|
|
jsonarray: JSONArrayFetch,
|
2021-12-17 09:22:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const fetchData = (datasource, options) => {
|
|
|
|
const Fetch = DataFetchMap[datasource?.type] || TableFetch
|
|
|
|
return new Fetch({ datasource, ...options })
|
|
|
|
}
|