https://github.com/pgedge/prest-client
https://github.com/pgedge/prest-client
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pgedge/prest-client
- Owner: pgEdge
- License: mit
- Created: 2024-02-28T09:18:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-05T16:31:03.000Z (over 1 year ago)
- Last Synced: 2025-08-11T20:42:15.515Z (11 months ago)
- Language: TypeScript
- Size: 322 KB
- Stars: 0
- Watchers: 15
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Prest Client
[](https://github.com/pgEdge/prest-client/actions/workflows/continuous-integrations.yaml)
[](./LICENSE)
[](https://bundlephobia.com/package/prest-client)
[](https://bundlephobia.com/package/prest-client)
[](https://bundlephobia.com/package/prest-client)
`prest-client` is a TypeScript/JavaScript library that provides a convenient interface for interacting with the [pRESTd](https://docs.prestd.com/) API. It allows you to perform various operations on your PostgreSQL database, including CRUD operations, filtering, joining tables, advanced queries and so on.
## Features
- **CRUD Operations**: Create, read, update, and delete data from your PostgreSQL database.
- **Filtering**: Apply various filters to your queries, such as `page`, `pageSize`, `select`, `filterEqual`, and more.
- **Function Operations**: Perform aggregate functions like `sum`, `avg`, `max`, `min`, `stdDev`, and `variance`.
- **Advanced Queries**: Utilize advanced query capabilities like `filterRange`, `join`, `textSearch`, and more.
- **Batch Operations**: Insert multiple rows into a table with a single operation.
- **TypeScript Support**: Written in TypeScript, providing type safety and better tooling support.
## Installation
This library is published in the NPM registry and can be installed using any compatible package manager.
```sh
npm install prest-client --save
# For Yarn, use the command below.
yarn add prest-client
```
### Installation from CDN
This module has an UMD bundle available through JSDelivr and Unpkg CDNs.
```html
// UMD module is exposed through the "prestClient" global variable.
console.log(prestClient);
```
## Usage
Here's a basic example of how to use prest-client:
```typescript
import { PrestApiClient, type PrestApiClientOptions } from 'prest-client';
const options: PrestApiClientOptions = {
base_url: envs.BASE_URL,
user_name: envs.USER_NAME,
password: envs.USER_PASSWORD,
database: envs.DATABASE_NAME,
};
const client = new PrestApiClient(options);
// Fetch users
const fetchUsers = async () => {
const response = await client.table('users').list().execute();
console.log(response);
};
// Insert data
const insertData = async () => {
const data = {
user_id: 1,
user_name: 'john doe',
};
const response = await client.table('users').insert(data).execute();
console.log(response);
};
```
For more examples, please refer to the [examples](https://github.com/pgEdge/prest-client/tree/examples) directory in the repository.
## Documentation
[Documentation generated from source files by Typedoc](./docs/README.md).
## Contributing
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
## License
Released under [MIT License](./LICENSE).