typeorm-mui-query
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

MUI TypeORM QueryBuilder

If you use TypeORM and MUI Data Grid server-side filter or server-side sorting this project can be helpful.

Install

npm install typeorm-mui-query

Example

Frontend

const [queryOptions, setQueryOptions] = useState({
  filterModel: {
    items: [],
  },
  sortModel: [],
})

const handleSortModelChange: DataGridProProps['onSortModelChange'] = useCallback((sortModel) => {
  setQueryOptions((currentState) => ({ ...currentState, sortModel }))
}, [])

const handleFilterModelChange: DataGridProProps['onFilterModelChange'] = useCallback(
  (filterModel) => {
    setQueryOptions((currentState) => ({ ...currentState, filterModel }))
  },
  []
)

const query = new URLSearchParams({
  ...queryOptions,
  sortModel: JSON.stringify(queryOptions.sortModel),
  filterModel: JSON.stringify(queryOptions.filterModel),
})
const results = await API.get('default', `/example?${query.toString()}`, {})

Backend

import { handleQuery } from 'typeorm-mui-query'

handleQuery({ qb, queryStringParameters })
const results = await qb.getMany()

Readme

Keywords

Package Sidebar

Install

npm i typeorm-mui-query

Weekly Downloads

9

Version

1.3.1

License

MIT

Unpacked Size

12.4 kB

Total Files

10

Last publish

Collaborators

  • webjay