Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lunaroyster/repldb-deno
A deno client for ReplDB (WIP)
https://github.com/lunaroyster/repldb-deno
deno denoland repldb replit
Last synced: 23 days ago
JSON representation
A deno client for ReplDB (WIP)
- Host: GitHub
- URL: https://github.com/lunaroyster/repldb-deno
- Owner: lunaroyster
- License: mit
- Created: 2020-06-28T04:15:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-29T01:06:46.000Z (over 4 years ago)
- Last Synced: 2025-01-09T13:28:29.925Z (25 days ago)
- Topics: deno, denoland, repldb, replit
- Language: TypeScript
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# repldb-deno
ReplDB Deno is just that, a client for ReplDB written for use in Deno and other TypeScript environments.
## How to use
### Importing ReplDB
First, you want to import the ReplDB Client. In Deno, you can import it directly from its GitHub URL
```typescript
import { ReplDBClient } from 'https://raw.githubusercontent.com/lunaroyster/repldb-deno/master/mod.ts';
```
### Initializing ReplDBTo initialize, use one of these:
```typescript
// This only works if REPLIT_DB_URL is defined, which should be the case when running in Repl.it
const replDB = ReplDBClient.createFromEnv();
``````typescript
const dbUrl = Deno.env.get('REPLIT_DB_URL');
const replDB = new ReplDBClient(dbUrl);
```#### JSON mode
You can also initialize ReplDB in json mode, which automatically serializes and deserializes values to JSON strings before storing in ReplDB.
```typescript
const replDB = new ReplDBClient(dbUrl, { mode: 'json' });
```Or,
```typescript
const replDB = ReplDBClient.createFromEnv({ mode: 'json' });
```### CRUD operations
Here's some examples
```typescript
// Setting a value for a given key
await replDB.set('date', '6/28/2020');// Getting a value
let date = await replDB.get('date');
console.log(date);
// 6/28/2020// Listing all keys
let keys = await replDB.list();
console.log(keys);
// [ "date" ]// Deleting a key (and its value)
await replDB.delete('date')
console.log(await replDB.list().length === 0)
// true```
### Group operations (wip)
### Core functions
The client contains 'Core functions' that are wrappers around the main http calls. These start with a capital letter.