https://github.com/vlucas/seamless-cloud-js
JavaScript (Web + Node) Client for Seamless.cloud
https://github.com/vlucas/seamless-cloud-js
database javascript nodejs sql
Last synced: 3 months ago
JSON representation
JavaScript (Web + Node) Client for Seamless.cloud
- Host: GitHub
- URL: https://github.com/vlucas/seamless-cloud-js
- Owner: vlucas
- License: bsd-3-clause
- Created: 2020-11-25T17:47:00.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-25T15:19:43.000Z (about 4 years ago)
- Last Synced: 2025-01-16T13:56:33.101Z (over 1 year ago)
- Topics: database, javascript, nodejs, sql
- Language: TypeScript
- Homepage: https://www.seamless.cloud
- Size: 26.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Seamless.cloud JS Client
This JS client is for Node.js and is currently SERVER-SIDE ONLY.
PLEASE don't use this client-side. You don't want to leak your API key and let any rando run SQL queries against your
database...
## Install
Install with NPM or Yarn:
```javascript
npm i seamless-cloud
```
## Usage
You must initialize the `SeamlessClient` class with a `SeamlessClientConfig` object, and a `fetch` function to use.
Specifying this function yourself keeps this client portable across server and client applications.
```javascript
import { SeamlessClient, sql } from 'seamless-cloud';
const client = new SeamlessClient(
{
account: 'accountUsername',
project: 'project-name',
apiKey: 'my-api-key-here',
},
fetch
);
```
Once initialized, you can now run queries using the `sql` helper (imported from `seamless-cloud`):
```javascript
const authorId = 1;
const results = await client.query(sql`SELECT * FROM posts WHERE authorId = ${authorId} LIMIT 20`);
```