@withkoji/database

1.0.28 • Public • Published

Koji Database (deprecated)

npm (scoped)

SDK for communicating between a Koji template and its in-built database service.

Overview

The @withkoji/database package enables you to implement a Koji database for the backend of your template. A Koji database is a key-value store that is included with each project on Koji.

[DEPRECATED] This package is deprecated and is included only for backwards compatibility. For new templates, use @withkoji/core.

Installation

Install the package in the backend service of your Koji project.

npm install --save @withkoji/database

NOTE: To support instant remixes of your template, you must also install the @withkoji/vcc package and implement the VccMiddleware on your backend server. This middleware maintains the environment variables for instant remixes, ensuring that database access is restricted to the correct remix version.

Basic use

Import and instantiate the database SDK in the backend service.

import Database from '@withkoji/Database';
const database = new Database({
  projectId: res.locals.KOJI_PROJECT_ID,
  projectToken: res.locals.KOJI_PROJECT_TOKEN,
});

Set database entries in the database using the SDK.

const isAdded = await database.set('myCollection', 'myKey', {'myValue':1});

Get database entries from the database using the SDK.

const myEntry = await database.get('myCollection','myKey');

Related resources

Contributions and questions

See the contributions page on the developer site for info on how to make contributions to Koji repositories and developer documentation.

For any questions, reach out to the developer community or the @Koji Team on our Discord server.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.28
    1
    • latest

Version History

Package Sidebar

Install

npm i @withkoji/database

Weekly Downloads

1

Version

1.0.28

License

MIT

Unpacked Size

65.8 kB

Total Files

10

Last publish

Collaborators

  • victordemin
  • feliksg-koji
  • osedania
  • sthielen