@osaas/client-db
TypeScript icon, indicating that this package has built-in type declarations

0.6.3 • Public • Published

@osaas/client-db

SDK for Open Source Cloud DB services

Usage

Prerequisites

npm install --save @osaas/client-db

Example code creating a Valkey database and use a Redis client to connect with it

import { Context } from '@osaas/client-core';
import { setupDatabase } from '@osaas/client-db';
import Redis from 'ioredis';

async function main() {
  const ctx = new Context();
  const dbUrl = await setupDatabase(ctx, 'valkey', 'myvalkey', {
    password: 'secret'
  });
  const client = new Redis(dbUrl);
  try {
    await client.subscribe('messages');
    console.log('Waiting for messages...');
    client.on('message', (channel, message) => {
      console.log(`Received message: ${message} from ${channel}`);
    });
  } catch (err) {
    console.error('Error:', err);
  }
}

main();

Readme

Keywords

none

Package Sidebar

Install

npm i @osaas/client-db

Homepage

www.osaas.io

Weekly Downloads

559

Version

0.6.3

License

MIT

Unpacked Size

21.6 kB

Total Files

11

Last publish

Collaborators

  • jobi
  • isabella.viksten
  • ggeyevinn
  • _volcano
  • sandramel
  • tom_snooze
  • malmen237
  • mollgan
  • zeynepsude
  • armin-164
  • xistenz