Updated Packages & Added Pagination data with frontend support.
Pre-release
Pre-release
MongoDB Package has been updated to 4.7.0
.
Pagination types for backend and frontend usage are now available in a single file.
Paginated Type
import type {Paginated} from "xpress-mongo/src/types/pagination";
const users: Paginated<User> = await api.get('/path/to/paginated/resource');
users.total // Total results
users.perPage // Results per Page
users.page // current page
users.lastPage // last page
users.data // paginated data
Paginated Function
Paginated
is also a function that returns typed default pagination data
import {Paginated} from "xpress-mongo/src/types/pagination";
const users = Paginated<User>();
// users will have default paginated data.
An example using vue
<script lang="ts" setup>
import {Paginated} from "xpress-mongo/src/types/pagination";
const users = ref(Paginated<User>());
// users will have default paginated data.
</script>